Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library
What is the reason for the following error I am having:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library.
I am using Eclipse 3.5 SE on Ubuntu 9.04 Jaunty.
How 开发者_StackOverflow社区can I resolve this error?
I had same problem with Oracle Java 7 and Eclipse on 32-bit system.
libswt-gtk-3.6-java
and libswt-gtk-3.6-jni
were already installed. What helped:
cd ~/.swt/lib/linux/x86
ln -s /usr/lib/jni/* .
Maybe this can be done reconfiguring Java alternatives or what.
I believe Mikolaj Lechtanski's workaround is more elegant.
create or edit /etc/eclipse.ini
Paste inside:
-vmargs -Djava.library.path=/usr/lib/jni
exit
make sure the file is readable:
sudo chmod 755 /etc/eclipse.ini
This means the native libraries could not be found.
Either you have 32-bit libraries and you are running on a 64-bit machine or vice-versa.
also make sure you have the -Djava.library.path=
set properly
See this page on how to run outside of eclipse
What versions of Java and Eclipse are you using, and are they 32-bit or 64-bit, and how did you install them?
Eclipse uses its own GUI library called SWT (it doesn't use Java's AWT or Swing), and it needs some native (non-Java) libraries for this. If you have 32-bit Java installed, you need 32-bit Eclipse; if you have 64-bit Java installed, you need 64-bit Eclipse (note, the Eclipse downloads page has 32-bit and 64-bit versions for Linux).
(Note that it doesn't depend on whether your Linux OS is 32-bit or 64-bit, but on whether your Java is).
I had a similar issue when running Eclipse remotely on a server via a "ssh -X" tunnel. I resolved it using "sudo apt-get install libswt-gtk-3.6-java" on the server.
Happened to me when starting some GUI java application on a headless server using X11 forwarding while only having openjdk-7-jre-headless
installed. Installing the full jre solved the problem:
apt-get install openjdk-7-jre
I ended up doing
cd ~/.swt/lib/macosx/x86_64
ln -s /usr/lib/java/* .
which fixed that problem.
精彩评论