This site runs best with JavaScript enabled.

A nice way to launch SWT applications

Torsten Uhlmann

April 25, 2006

AGYNAMIX, Blogger, Java, Scala, Javascript, Typescript, ReactJS

Photo by Torsten Uhlmann

programming

SWT (the low level GUI toolkit used by Eclipse and a lot of other Java based apps) needs platform dependent libraries (.dll on Windows and .so on Unix). Normally you have to tell Java where it will find those libs. This is another way to launch SWT applications without the need to set -Djava.library.path to Java or to put the libs into a system wide path. main() would look like this:

public static void main(String[] args) throws Exception { URL[] urls = ; File workDir = ; ClassLoader cl = new SWTClassLoader(urls, workDir); Class mainClass = cl.loadClass(); Method main = mainClass.getMethod("main", new Class[] { String[].class }); main.invoke(null, new Object[] { args }); }

[SWTClassLoader](./SWTClassLoader.zip) Thanks to Peter Nehrer for this tip.
Share article