Ubuntu – Cannot load SWT library “UnsatisfiedLinkError: no swt-gtk-4233”

eclipsejava

I'm a Java newbie who just a made a simple Java program using SWT for GUI via eclipse Juno.
The code was working and the program was able to run inside eclipse, so I compiled it and made it a runnable jar file so it can be run outside eclipse.
I tried to run it using the terminal and this error came up.

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
no swt-gtk-4233 in java.library.path
no swt-gtk in java.library.path
Can't load library: /home/abody/.swt/lib/linux/x86_64/libswt-gtk-4233.so
Can't load library: /home/abody/.swt/lib/linux/x86_64/libswt-gtk.so

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.C.<clinit>(C.java:21)
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 Class1.main(Class1.java:12)

So now it looks like it can't find libswt-gtk-4233.so and the other file. However, when I took a look at the .swt folder I had an libswt-gtk-3740.so not 4233.

So its trying to find a file that is more up-to-date. So what does that mean, should I update SWT? what's going on?

Best Answer

You need to make a symbolic link to the swt so files located in the /usr/lib/jni directory. I found a solution on this site: Eclipse cannot load SWT libraries.

use this command:

ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/
Related Question