将所有jar合并或合并在一个可执行jar中 [英] Combine or merge all jars in one executable jar
问题描述
这里有一个简单的问题,但使用Eclipse做这样的事情似乎很复杂。
Kind of a "simple" question here, but it seems complicated to do such a thing using Eclipse.
我有一个utils项目,其中我已经开发了常用代码,如xml解析器,记录器,数学计算,调试实用程序等。
I have a "utils" project, in which I have developped "common" code like xml parsers, loggers, maths calculations, debug utilities and such.
此库基于其他几个外部库(commons-lang-3.1 ,colt-1.2.0,jdom-2.0.4)工作,它是一个不可运行的JAR文件(即没有main(),只包括在其他项目中的实用程序代码)
This library is based on several other external libs (commons-lang-3.1, colt-1.2.0, jdom-2.0.4) to work, and it's a non-runnable JAR file (ie, there is no main(), just utility code to include in other projects).
我想要做的是,当我创建我的项目的JAR文件时,将JAR文件中的所有外部JAR(common-lang,colt,jdom) ,以便自动将其用于其他项目。
What I want to do is, when I create the JAR file of my project, extract all external JARs (common-lang, colt, jdom) in the JAR file, in order to automatically use them on other projects.
原因是我不想在每个基于项目的基础上重新包含common-lang,colt和jdom在我的lib上,但是使用我的lib JAR文件中包含的那些(并且它是一种方法,以确保我将在基于我的lib的项目中使用相同版本的这些库)
The reason is that I don't want to re-include common-lang, colt and jdom on every projects based on my lib, but use the ones packed in my lib JAR file (and it's a way to ensure that I'll be using the same version of those libs in the projects based on my lib, too)
我知道如何使用可运行的JAR文件执行此操作。
例如:如何使用Eclipse中包含的外部库创建一个jar?
I know how to do that with a runnable JAR file. See for instance : How to create a jar with external libraries included in Eclipse?
但是在一个不可运行的JAR文件中:
But in a non-runnable JAR file :
- 所有我的类根据我创建的包(希望; - )),
- 正确的目录结构导出,但外部JAR文件是导出原样,所以当我在另一个项目中导入我的JAR时,这些JAR(common-lang,...)不能被看到,我必须重新导入它们。
有没有一种简单的方法来导出这个JAR文件,其目录结构也是在生成的JAR文件中提取所有外部JAR文件?
Is there a simple way to export this JAR file with a directory structure in which all external JARs files are extracted in the generated JAR file, too ?
注意
推荐答案
你看过 JarSplice ?
JarSplice将所有的罐子和本地文件转换成一个易于使用的GUI文件,易于使用的可执行文件。
JarSplice merge all your jars and native files into one, easy to use executable jar file via an easy to use GUI.
这篇关于将所有jar合并或合并在一个可执行jar中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!