Search code examples
javacross-platformswtcompatibilityunsatisfiedlinkerror

Exported jar from Eclipse works on Linux but not Windows


I have a program which I wrote in Eclipse on Ubuntu. I exported the program into a runnable .Jar and it works fine on Linux systems. If I try to use it on a Windows system I get an UnsatisfiedLinkError related to two SWT .Dll files. I've been trying to open it by typing in the command line:

java -jar <filename>.Jar`

Is there a way I can pack these .Dll files into the runnable .Jar? I've never encountered this error before so I'm really not sure what to do. Any help is very much appreciated.


Solution

  • I solved the issue by using SWTJar.

    SWT is a Java widget toolkit that provides access to native UI elements. This presents a problem when it comes to packaging an application as you need to include a different SWT jar for each platform (Windows/Linux/OSX)/(32/64bit). To support all of these standard platforms you have to build and distribute 6 different packages which isn't really in the spirit of Java's write once, run anywhere.

    How it works:

    SWTJar is an ant task which allows you to build a single jar which loads the correct SWT classes at runtime allowing you to distribute a single jar which works across (Windows/Linux/OSX)/(32/64bit).

    Just in case anyone else runs into this problem! :)