Java – Eclipse: How to build an executable jar with external jar

classpatheclipseexternaljarjava

I am trying to build an executable jar program which depends on external jar downloaded. In my project, I included them in the build path and can be run and debug within eclipse.

When I tried to export it to a jar, I can run the program but I can't when I try to press a button which includes function calls and classes from the external jar. I have edited the environment variables (Windows XP) CLASSPATH to include paths of all the external jar, but it doesn't work.

A point to note is that I got compile warnings while exporting my executable jar, but it doesn't show up any description about the warnings.

Would someone kindly provide a thorough guide on how to include an external jar program using eclipse?

Best Answer

Eclipse 3.5 has an option to package required libraries into the runnable jar. File -> Export... Choose runnable jar and click next. The runnable jar export window has a radio button where you can choose to package the required libraries into the jar.