I sure hope you get a good response to this.
I've got a very similar question and perhaps what's written below will help you some. The following is a post I made on eclipse.org's SWT forum. I have gotten only one response to this, and it was "...maybe eclipse doesn't work... go use a command line utility from Sun." Not happy with that.
They say they want you to do your homework, check FAQ's use google, research old posts, etc., before posting at eclipse.org. Ironically, the better of a job you do, the less response you get, while the experts there happily answer really lazy questions like "where can I find a tutorial?" (which should take 5 seconds on google).
I have a lot more confidence in this forum and will probably post the following here after I do a little more research. I would even hope that after we iron this out, instantiations would make it one of their articles.
The one thing I can be pretty confident about is this: if you use Eclipse 3.0.1 or 3.0.2 and follow my recipe below, you will succeed.
If, however, you're determined to wrap your app and the SWT/JFace libs all into one SINGLE jar, you should know there's a utility out there that claims to do this. I think it's at
http://one-jar.sourceforge.net/. I tried it briefly and didn't like how slowly it ran (i.e., how long it took to build the single jar). It is a cool idea and probably worth another look. Please report back any findings here.
==============
***BACKGROUND
In eclipse 3.0.x, we used the
File, Export Jar function to make a jar file
of our app. We used a manifest file that specified the main class and had
a Class-Path stmt that specified SWT/JFace support jars. We successfully
deployed those jars in a lib folder beneath the app folder on various
Windows 2000 and XP machines. (We also installed the SWT support DLL,
JDBC drivers and various other support files that probably aren't relevant
to this problem.)
The manifest file looked like this:
Manifest-Version: 1.0
Main-Class: com.companyname.pkgname.etc.MainWindow
Class-Path: lib\swt.jar lib\jface.jar lib\runtime.jar lib\jfacetext.jar
lib\osgi.jar lib\text.jar
(The Class-Path line in the actual file was one line.)
This all worked well.
***NEW SITUATION
Now, with Eclipse 3.1, the above jars are renamed in a better, more
consistent way that includes version numbers. The new file names are
considerably longer - 170 characters total - so fitting them all on one
line may be a concern.
Obviously, we need to restructure our jar building process a bit. We've
done that in too many ways to list here, but would be happy to enumerate,
if asked.
***PROBLEM
1. After days of trying, we can't build a jar file that works. Every jar
we build causes the JVM Launcher to fail with "Could not find main class."
2. When launching on a command line with:
java -jar appname.jar
the error message is:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/jface/window/ApplicationWindow
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass
(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
(The above is a test of a stripped down app. It's a blank JFace
ApplicationWindow and nothing else. This was to make sure 3rd party libs
weren't the issue)
***QUESTIONS
1. Any thoughts on what's wrong here?
2. Is the list of libraries to support SWT and JFace different with 3.1?
3. With Eclipse 3.1, has anyone succeeded in using File, Export Jar to
make a jar that they simply doubled click on, and it ran in Windows?
TIA, all responses appreciated!
=============
***FURTHER COMMENTS
1. In case you're interested, we used zerog.com's InstallAnywhere. It's pretty cool because it is very java friendly and will even install a JVM. This produced the easy, seamless, shrink-wrap kind of installation experience we sought: everything including Java gets installed simply running one setup.exe, and they're supposed to work for platforms other than win32 as well. The only issues we have with IA are:
* We now have to upgrade to v7.x to get java 1.5 support.
* They are pricey.
2. When you use SWT-Designer to build a JFace app, you can look in the Package Explorer and see what libs it puts into the Java Build Path for you:
org.eclipse.core.runtime_3.1.0.jar
org.eclipse.jface.text_3.1.0.jar
org.eclipse.jface_3.1.0.jar
org.eclipse.osgi_3.1.0.jar
org.eclipse.swt.win32.win32.x86_3.1.0.jar
org.eclipse.ui.forms_3.1.0.jar
org.eclipse.ui.workbench_3.1.0.jar
These files can all be found in the root of the plug-ins folder. So if that's what it takes to compile, maybe it's what is needed to run??? (though I have some doubts and other thoughts I won't go into here for now).
So, I tried copying them all to a lib folder under my app, edited the manifest file accordingly, and built a jar using File, Export Jar. So far, that hasn't worked either.
I come from the win32 world where I would have solved this problem long ago using some utility (like depends.exe provided by MS) to identify the various libraries (DLL's) I need to ship. I wonder: is there such a utility in the Java world?