[英]how to combine jar files from dist folder and jar files in lib within dist folder to make a single jar file using build.xml
How does one combine jar files from dist folder and jar files in lib within dist folder to make a single jar file using build.xml
.如何使用build.xml
将 dist 文件夹中的 jar 文件和 dist 文件夹内 lib 中的 jar 文件组合成单个 jar 文件。 Currently I use the following code to make single jar, but it will show the message "A java exception has occurred".目前我使用以下代码制作单个 jar,但它会显示消息“发生 Java 异常”。
. .
<?xml version="1.0" encoding="UTF-8"?>
<project name="CIH_Billing" default="jar">
<target name="jar">
<zip destfile="output.jar">
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<zipgroupfileset dir="dist" includes="*.jar"/>
</zip>
</target>
</project>
You don't.你没有。 Valid JAR files cannot contain other JAR files.有效的 JAR 文件不能包含其他 JAR 文件。 If you really, really want to do this there are ways, but you need to think long and hard about the reasons for justifying this.如果你真的,真的想这样做,有很多方法,但你需要仔细思考证明这一点的原因。 Using something like Jar Jar Links for instance, while raising other issues does do what you want.例如,使用Jar Jar Links 之类的东西,同时提出其他问题确实可以满足您的需求。 Alternatively, you can extract all the jars and combine them manually, which also has it's drawbacks.或者,您可以提取所有罐子并手动组合它们,这也有其缺点。
However as a general rule of thumb java applications are distributed as a bundle and launched with a small batch script (which sets the classpath and launches the main method).然而,作为一般经验法则,java 应用程序作为一个包分发并使用一个小批处理脚本(它设置类路径并启动 main 方法)启动。 If you don't want to do it this way, but want a standalone jar, there is always Jar Jar Links , if you want a stand alone Windows binary.如果你不想这样做,但想要一个独立的 jar,如果你想要一个独立的 Windows 二进制文件,总是有Jar Jar Links 。 you can always use something like Excelsior JET or Avian .你总是可以使用Excelsior JET或Avian 之类的东西。
Using either with Ant though was somewhat complicated last time I checked.虽然上次我检查时使用 Ant 有点复杂。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.