My computer is win7 64 bit, and jdk is 1.7.0.21,jvm is 1.6.. and 64 bit I want to run SWT application and export as runnable jar file. When I run the application, it has the exception that Cannot load 32-bit SWT libraries on 64-bit JVM, so I import the SDK as alternate jre just like you point at Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file ), and in Eclipse, the application can run correctly, but when I edit the bat file to run the jar file, it always has the problem like Cannot load 32-bit SWT libraries on 64-bit JVM, I have the swt.jar for 64 bit, but I don't konw how to replace and I wanna edit the bat file with the information with the SDK. How to handle the problem?
-
1Please clean up your formatting. – nanofarad Aug 12 '13 at 15:03
-
A 32-bit shared library can only be loaded by a 32-bit application. This is a limitation of the OS and you can't change this. If you have a 32-bit DLL, you can only load this in 32-bit JVM, If you have a 64-bit DLL, you can only load this with a 64-bit JVM. This would be the same if you use C or C++ etc. It is not something you can simply work around and even in Linux and Solaris, the same limitation applies. – Peter Lawrey Aug 12 '13 at 15:10
-
sorry about that ,can you say more detailed ,cause I don't have a deep learning of JVM or swt mechnism – sophia2046234 Aug 12 '13 at 15:47
5 Answers
You have a 64bit JVM so it won't run the 32-bit SWT libraries. You need to either:
- Download and install the 32bit JVM and change your project's settings to run the 32bit JVM instead of the 64bit one.
- Download and install the 64bit libraries instead.
This previous SO question has a great description of the first option with accompanying diagrams:
Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )

- 1
- 1

- 5,619
- 10
- 54
- 92
-
hi,first is the application run correctly in eclipse environment for I have import the alternate jre SDK(ibm.com..), but when i export the project and use the bat file to run the runnable jar file ,it has the error, I don't know how to export the sdk information into bat file ,that is when running the bat file ,it comes instead of eclipse ,so the solution seems not suitalbe – sophia2046234 Aug 12 '13 at 15:45
-
The simplest solution would be to use the 64bit libraries (otherwise there's no point in using a 64bit JVM). Can you do that? – Andrew Martin Aug 12 '13 at 15:52
-
so sorry , I have no idea about how to replace the 32 bit swt.jar with 64 bit swt.jar – sophia2046234 Aug 12 '13 at 15:58
-
@sophia2046234: You'd need to download them. Google for the download link. – Andrew Martin Aug 12 '13 at 15:59
-
You should be able to google step by step instructions. Get it working on Eclipse first, then work on the bat file – Andrew Martin Aug 12 '13 at 16:19
-
@ Andrew Martin,it's so strange,fortunately ,I solve it~~FOR the exported jar file has contains the 32 bit swt lib and it will be loaded automatically, and in the eclipse plugins I didn't find the org.eclipse.swt.*,so after replacement ,it's ok ,thanks all the same – sophia2046234 Aug 13 '13 at 06:32
64-bit JVM ? you should use the 64-bit swt

- 9
- 1
-
hi, yeah ,I know I should use 64-bit instead ,but the key is I don't kown how to ,can you teach me in details – sophia2046234 Aug 12 '13 at 15:51
Apart from the appropriate swt lib corresponding to the Operating system and their bitness, sometimes consider the following also:
My environment:
32 bit Ubuntu
32 bit JVM/JRE
Eclipse running using the 32 bit JRE
32 bit Gtk SWT
Approach 1: I faced the problem when I was replacing the 32 bit swt with 64 bit swt to test on other platforms. To resolve, I had to remove/clean the project and rebuild the project with the 64 bit swt. But this step logically does not make sense, still works.
Approach 2: All my swt libs for each O/S had the same name- "swt.jar" residing in different folders. I only changed to the appropriate lib when testing, i.e., 32 and 64 bit o/s both has swt.jar. Now this was somehow causing some problem. Not yet able to identify. But on changing the name to something different for each of the swt lib files, it got resolved. This step also does not make much sense.
Approach 3: I am working using geotools api version 10.5 which also contains an swt library in the bin folder. I had to remove it from the folder (move to alternate location) and now my app runs smooth!!

- 43
- 5
My dificult to work with SWT is the distribution. It's require a installation for each SO (Linux, Windows | 32, 64), Swing no have this problem and is cool, but I prefer SWT/JFace.
To solve this problem I create a Ant script to zip each installation with its rightful swt jar.
I get the specific swt jars in:
http://archive.eclipse.org/eclipse/downloads/drops/R-3.6.1-201009090800/index.php#SWT

- 991
- 15
- 24