views:

6556

answers:

5

Hi. I need to export jar from my Eclipse Java project and I want to include the referenced libraries. I can't use fatjar for this, which is what everyone seems to recommend. There must be another way of doing this. Does anyone know what this is?!

+4  A: 

The next version of Eclipse (3.5, due next June) has an option to include all necessary jars. It was introduced in 3.5M5 (thanks, basszero).

Or you can try to build your project with Maven 2. Then, you can build a "fat" jar with mvn assembly:assembly.

Another option is to use ant. Unpack all JAR files into a temp directory and jar them up again.

Aaron Digulla
The recent milestone version of Eclipse (3.5M5) includes the feature you just mentioned.
basszero
A: 

I guess you could modify your build script to include the libraries. If I undestand correctly you can put into your <jar destfile="myProject.jar"> ... <zipfileset src="theExternalLib.jar"> </jar>

Jens Jansson
A: 

If you can say why fatjar isn't an option (or the embedded one-jar) it would be helpful to determine a suitable replacement.

Thorbjørn Ravn Andersen
+2  A: 

I think its version 3.3 of Eclipse (ganymede) that has Export as Runnable JAR file. Last time I tried it, it did include the referenced libraries and also un-jars all the jars.

Bernie Perez
A: 

Thanks Bernie! I was wondering if there was a way to do this in eclipse without any third party utils. That worked perfectly!