I trying to learn swt, and I use maven for all my builds and eclipse for my IDE. When getting the swt jars out of the maven repository, I get:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3034 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:100)
at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:19)
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:112)
at wenzlick.test.swt.main.Main.main(Main.java:30)
Has anyone successfully got a swt app to build and run using maven?
Edit: I did a little research and found the problem. look at my post below
-
From the API of UnsatisfiedLinkError
Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.
I haven't tried it myself, but I think you not only need to download the main SWT jar, but a supporting 'native' JAR for your platform. For example swt-linux-gtk if you're on Linux?
-
Sounds like Maven is pulling in an old version of SWT. As of v3.4 (and higher), the swt.jar is all you need. SWT will automatically extract the
.so
s,.jnilib
s or.dll
s as necessary. The only tricky thing you need to worry about is to ensure that you get the right swt.jar (meaning for your platform).Try installing SWT 3.4 in your local repository by hand. If that still gives you the same problem, then something is probably fishy. After that, I would try extracting the
.so
s manually and then specifying thejava.library.path
variable using the-D
switch on invocation. Sometimes on Linux the loading of the libraries can fail due to dependency problems (in things like libpango). In such cases, often the error will be just the genericUnsatisifedLinkError
, making the problem difficult to debug. -
I did a little more research on this and found that the swt jar is in a couple different places in the maven repository. I was using jars put out by the swt group, but after looking around a bit, I found the jars put out by the org.eclipse.swt.gtk.linux group for linux (org.eclipse.swt.win32.win32 for Windows). This is for the 3.3 version of swt. Still looking for 3.4.
Julien Nicoulaud : If this can help someone, I have started deploying SWT artifacts on my public repository: http://maven.ju-n.net/maven2/org/swt/
0 comments:
Post a Comment