问题
I am almost done with one Java project that I have been developing on Linux. Now I need to build and test it on Windows. So I have installed Eclipse on Windows XP 32-bit, and imported my project. All dependencies of project are in jar files in lib folder, and on Linux everything works well, but on Windows XP I get following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-pi-gtk-4234 in java.library.path
no swt-pi-gtk in java.library.path
Can't load library: C:\Documents and Settings\firzen\.swt\lib\win32\x86\swt-pi-gtk-4234.dll
Can't load library: C:\Documents and Settings\firzen\.swt\lib\win32\x86\swt-pi-gtk.dll
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:331)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240)
at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:22)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:133)
at gui.Frontend.<init>(Frontend.java:51)
at Fighter.main(Fighter.java:18)
I have searched for these DLLs, but I have failed to find them. Where can I download these DLL files?
Thanks in advance.
回答1:
Correct DLL files are inside swt.jar for your particular platform. You need to download SWT for Windows (not x86_64), e.g. "swt-4.2.1-win32-win32-x86.zip" from http://download.eclipse.org/eclipse/downloads/drops4/R-4.2.1-201209141800/#SWT.
It looks as if you have tried to use swt.jar from linux SWT. That won't work. You need to download platform-specific SWT package For each platform that you want to support.
回答2:
Use the *.jar
on windows. Go to Java Build Path. Remove all org.eclipse.swt.gtk.linux
and replace them by with org.eclipse.swt.win32
回答3:
I got a similar problem when I tried to do the "Hello World SWT" tutorial included in Eclipse 4.4.0.
In this case, the solution was really simple. I got it from Craig Williams's answer in http://www.eclipse.org/forums/index.php/t/261606/
"For me the solution lay in the step of the tutorial titled 'Configure the Java project'. Go into the project Properties and select Java Build Path then make sure you are in the Projects tab where you added the SWT project earlier. Expand the reference to the SWT project. Where is says Native library location I found that when I followed the tutorial it said (None). I clicked Edit and found the SWT project in my workspace obviously when I added it earlier in the tutorial. Select this and click OK."
Hope it can help somebody else who got to this page.
来源:https://stackoverflow.com/questions/13962165/could-not-load-swt-library-on-windows-32-bit