Create cross platform Java SWT Application

Posted by mchr on Stack Overflow See other posts from Stack Overflow or by mchr
Published on 2010-04-24T21:26:38Z Indexed on 2010/04/24 21:43 UTC
Read the original article Hit count: 229

Filed under:
|
|
|
|

I have written a Java GUI using SWT. I package the application using an ANT script (fragment below).

<jar destfile="./build/jars/swtgui.jar" filesetmanifest="mergewithoutmain">
  <manifest>
    <attribute name="Main-Class" value="org.swtgui.MainGui" />
    <attribute name="Class-Path" value="." />
  </manifest>
  <fileset dir="./build/classes" includes="**/*.class" />
  <zipfileset excludes="META-INF/*.SF" src="lib/org.eclipse.swt.win32.win32.x86_3.5.2.v3557f.jar" />
</jar>

This produces a single jar which on Windows I can just double click to run my GUI. The downside is that I have had to explicitly package the windows SWT package into my jar.

I would like to be able to run my application on other platforms (primarily Linux and OS X). The simplest way to do it would be to create platform specific jars which packaged the appropriate SWT files into separate JARs.

Is there a better way to do this? Is it possible to create a single JAR which would run on multiple platforms?

© Stack Overflow or respective owner

Related posts about java

Related posts about swt