I have a problem deploying an application with SWT components.
I read SO link and incorporated SWT with swing into my code.
When I run it in eclipse 3.7.1 Indigo (Ctrl+F11 or Alt + Shift X, J).
It runs perfectly inside eclipse.
However when I export the file as a "runnable JAR":
The application itself runs fine, but the SWT file choosers don't.
When I export the file as a JAR, i.e. adding the manifest according to: wiki eclipse link + SO link + SO link + SO link and I get the error listed in the troubleshoot section (eclipse wiki). I checked all the solutions listed there but they didn't work for me.
Questions:
- Why do SWT file choosers work in eclipse and not in a "runnable jar"?
- Why does the "runnable jar" export wizard in eclipse, not automatically incorporate SWT?
- Why does the export as jar not work with the manifest, when the
swt.jar
is correctly named and in the runtime folder and the main class is correct,but it still gives the error?:
Could not find the main class. Program will exit.
I am assuming the simplest solution would be to just use Swing file choosers. But I wanted to know how to get SWT applications to run outside eclipse.
Regards
UPDATE: Turns out that all the .jar
files (in the library build path) need to be added to the manifest. I was just adding the swt.jar
which is why I was getting the Could not find main class...
error. Adding the other .jar
to the manifest solved Q3 above.
When running from command line: SWT components work fine when exporting both jar + runnable jars.
However, the SWT components don't work when trying to run the runnable jar by double clicking. Q1 and Q2 still unsolved (SWT file choosers don't work when double clicking but work in cmd java -jar
...).