if you want to have one assembly that runs on different platforms (Win / Mac / Linux / * nix) or architectures (32/64 bit), then you can link the SWT bank for each target platform with your installer, and then load the correct one dynamically at runtime (or your installer will copy the correct SWT jar during installation).
eg. let's say you want to support 32-bit and 64-bit Windows and Linux, you will have SWT banks:
lib/swt_win_32.jar lib/swt_win_64.jar lib/swt_linux_32.jar lib/swt_linux_32.jar
Make your ant script / installer all included (about 1.6 MB each), and then during code execution you can discover the OS and architecture using the properties of the Java system.
System.getProperty("os.name"); System.getProperty("os.arch");
to create the name of the correct jar file.
Loading a flag at runtime can be done by a custom class loader or by calling the protected method URLClassloader.addURL(URL url) using reflection.
I put the working code to perform this exact task on my website: http://www.chrisnewland.com/select-correct-swt-jar-for-your-os-and-jvm-at-runtime-191
If you can handle the smell of code, then this is a quick fix to a very common SWT problem.
source share