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?!
7 Answers
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.

- 1
- 1

- 321,842
- 108
- 597
- 820
-
1The recent milestone version of Eclipse (3.5M5) includes the feature you just mentioned. – basszero Feb 09 '09 at 13:09
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.

- 12,513
- 13
- 46
- 55
This feature of eclipse works just fine to dump only the referenced libraries into separate folder. "Export as Runnable Jar" with "Copy the referenced libraries into a subfolder .." option.

- 41
- 1
-
This is almost the same answer as that provided by @bernie-perez. Should have been posted as a comment to that answer instead. – cabad Oct 22 '13 at 18:25
Just posting a little (Helios) gotcha for using the Eclipse export Jar - you must first run (in Eclipse) a class with a main() method, otherwise the "Launch configuration" dropdown will be blank and you'll not be able to export.

- 6,662
- 4
- 37
- 57
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>

- 4,626
- 4
- 25
- 29
You can export an XML file from eclipse,then analyse the file to get the jars you want - see this link.

- 30,138
- 7
- 37
- 54

- 221
- 2
- 6
I used a maven project instead of a java project and it worked !

- 11
- 1
-
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 20 '22 at 19:47
-
This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32970092) – Attila T Oct 24 '22 at 00:47