PDA

View Full Version : Java SWT application error



hoagie
November 23rd, 2006, 05:34 PM
Hello fellow programmers.
I'm a new programmer to linux so forgive my stupidness.
I tried to create my first java SWT application but I came across some errors that I'm unable to understand and figure out.
When I try to run my program from Eclipse I get the following error.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-motif-3316 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at org.eclipse.swt.internal.Library.loadLibrary(Libra ry.java:123)
at org.eclipse.swt.internal.motif.OS.<clinit>(OS.java:18)
at org.eclipse.swt.graphics.Device.<clinit>(Device.java:115)
at HelloWorldSWT.main(HelloWorldSWT.java:14)


Any advised would be appreciated.
Hoagie

brak
November 23rd, 2006, 06:40 PM
did you put the swt library jars in yours project's building path?

hoagie
November 23rd, 2006, 06:56 PM
I tried that but I still get the same error message.

hoagie
November 23rd, 2006, 08:27 PM
So nobody knows how to solve this?

hod139
November 25th, 2006, 05:52 AM
You need to install Sun's version of java. See this howto (http://ubuntuforums.org/showthread.php?t=201378) (ignoring the parts on eclipse, unless you want eclipse) for how to set up sun's java.

hoagie
November 26th, 2006, 12:57 PM
It still didn't work. I guess I wasn't meant to be a programmer. ](*,)

shining
November 27th, 2006, 02:24 PM
Maybe you could start over from there:
http://www.eclipse.org/swt/examples.php

eheck
November 27th, 2006, 04:51 PM
The important part being item no 5 at the bottom of that page. You have to give the location where your swt native libraries are in the "-Djava.library.path=...".
"UnsatisfiedLinkError" always means a .so (or an entry point in a .so) can't be found (libswt-motif-3316.so in your case)

hod139
November 27th, 2006, 05:14 PM
Also, in linux (unlike Windows) the current directory is not part of the system include path. So you can't just put the .so files in the same directory and expect it to find them.

T_W
November 27th, 2006, 05:44 PM
The important part being item no 5 at the bottom of that page. You have to give the location where your swt native libraries are in the "-Djava.library.path=...".
"UnsatisfiedLinkError" always means a .so (or an entry point in a .so) can't be found (libswt-motif-3316.so in your case)

I beleive you can also set the LD_LIBRARY_PATH environment variable to the directory containing the shared library.

-Djava.library.path is a beter solution.

Are you sure you want to be using the Motif version of SWT and not the GTK version?