Tuesday, November 13, 2012

[Eclipse] export java project to jar with libraries/jars inside

Usually when you program on your own java projects you may need third party libraries in jar format to help you to solve your problem. If you want to package your own project into a jar file, and then when you run it you may meet NoClassDefError because eclipse doesn't package your libraries with your own code.

A simple solution is to use another Eclipse export option: export your project to a runnable jar file and choose "package required libraries into generated jar". And that's it. You can your jar file just by

java -jar yours.jar