Exception in thread "main" java.lang.UnsatisfiedLinkError: failed to load SWT library

What is the reason for the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to load SWT library.

I am using Eclipse 3.5 SE on Ubuntu 9.04 Jaunty.

How can I solve this error?

+6
java eclipse ubuntu
source share
7 answers

I had the same issue with Oracle Java 7 and Eclipse on a 32-bit system.

libswt-gtk-3.6-java and libswt-gtk-3.6-jni already installed. What helped :

 cd ~/.swt/lib/linux/x86 ln -s /usr/lib/jni/* . 

Perhaps this can be done by reconfiguring Java alternatives or what.

+17
source share

I believe Mikolai Lekhtansky's workaround is more elegant.

create or edit the /etc/eclipse.ini file

Paste inside:

 -vmargs -Djava.library.path=/usr/lib/jni 

Exit

make sure the file is readable:

 sudo chmod 755 /etc/eclipse.ini 
+3
source share

This means that no native libraries were found.
Either you have 32-bit libraries, or you work on a 64-bit machine, or vice versa.
also make sure you have -Djava.library.path= installed

See this page on how to work outside of eclipse.

+2
source share

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 graphics library called SWT (it does not use Java AWT or Swing), and for this it needs some proprietary (non-Java) libraries. If you have 32-bit Java installed, you will need 32-bit Eclipse; if you have 64-bit Java installed, you will need 64-bit Eclipse (note that Eclipse downloads contains 32-bit and 64-bit versions for Linux).

(Note that this does not depend on whether your Linux OS is 32-bit or 64-bit, but depends on your Java).

+2
source share

I had a similar problem when starting Eclipse remotely on a server through the ssh -X tunnel. I resolved it using "sudo apt-get install libswt-gtk-3.6-java" on the server.

+1
source share

It happened when I ran some kind of java GUI application on a headless server using X11 forwarding, only having openjdk-7-jre-headless . Installing full jre solved the problem:

 apt-get install openjdk-7-jre 
0
source share

I finished work

  cd ~/.swt/lib/macosx/x86_64 ln -s /usr/lib/java/* . 

who fixed this problem.

0
source share

All Articles