Eclipse Java; export jar, include referenced libraries, without fatjar

不羁的心 提交于 2019-12-28 02:06:10

问题


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


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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>




回答6:


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



来源:https://stackoverflow.com/questions/528007/eclipse-java-export-jar-include-referenced-libraries-without-fatjar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!