Eclipse Java;导出 jar,包括引用的库,没有 fatjar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/528007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse Java; export jar, include referenced libraries, without fatjar
提问by
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?!
我需要从我的 Eclipse Java 项目中导出 jar 并且我想包含引用的库。我不能为此使用 fatjar,这似乎是每个人都推荐的。必须有另一种方法来做到这一点。有谁知道这是什么?!
采纳答案by Aaron Digulla
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).
Eclipse 的下一个版本(3.5,将于明年 6 月发布)可以选择包含所有必需的 jar。它是在 3.5M5 中引入的(感谢,basszero)。
Or you can try to build your project with Maven 2. Then, you can build a "fat" jar with mvn assembly:assembly
.
或者您可以尝试使用Maven 2构建您的项目。然后,您可以使用mvn assembly:assembly
.
Another option is to use ant. Unpack all JAR files into a temp directory and jar them up again.
另一种选择是使用ant。将所有 JAR 文件解压到一个临时目录中,然后再次将它们打包。
回答by Jens Jansson
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>
我想您可以修改构建脚本以包含库。如果我理解正确,你可以放入你的
<jar destfile="myProject.jar"> ... <zipfileset src="theExternalLib.jar"> </jar>
回答by Bernie Perez
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.
我认为它的 Eclipse (ganymede) 3.3 版具有导出为Runnable JAR 文件。上次我尝试它时,它确实包含了引用的库,并且还对所有 jar 进行了解压。
回答by earcam
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.
只需发布一些(Helios)使用 Eclipse 导出 Jar 的陷阱 - 您必须首先(在 Eclipse 中)运行一个带有 main() 方法的类,否则“启动配置”下拉列表将为空白,您将无法出口。
回答by user674158
回答by inspiron
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.
eclipse 的这个特性可以很好地将引用的库转储到单独的文件夹中。“导出为 Runnable Jar”和“将引用的库复制到子文件夹 ..”选项。