简体   繁体   English

如何使用 build.xml 将 dist 文件夹中的 jar 文件和 dist 文件夹内 lib 中的 jar 文件组合成单个 jar 文件

[英]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 JETAvian 之类的东西。

Using either with Ant though was somewhat complicated last time I checked.虽然上次我检查时使用 Ant 有点复杂。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用build.xml从源文件夹创建jar文件 - Create a jar file from source folder with build.xml 如果可执行文件不在dist文件夹中,则它不会运行 - Executable Jar file is not running if it is out of dist folder 在netbeans中进行清理和构建后,从dist文件夹运行jar文件时无法读取xml文件 - xml file not reading when running the jar file from dist folder after cleaning and building in netbeans 如何使用Netbeans将文件夹包含到dist JAR中作为构建过程的一部分? - How can I include a folder into the dist JAR as part of the build process using Netbeans? Gradle:在已发布的 dist.zip 的 /lib 文件夹中添加 sources.jar 文件以及我的所有其他依赖项 - Gradle: Adding sources.jar file within /lib folder of published dist.zip along with all my other dependencies 如果我将PDF手动放在dist文件夹中,.jar可以正常工作。 清理并构建后,文件消失,应用失去一些功能 - .jar works correctly if I manually place PDFs in the dist folder. After clean and build, the files go and the app loses some functionality Maven构建损坏/ WEB-INF / lib文件夹中的jar文件 - Maven build corrupting jar files in /WEB-INF/lib folder 从jar文件中的文件夹加载所有文件 - Loading all files from a folder in a jar file 从jar文件中的文件夹中读取文件 - Read files from a folder inside a jar file 如何制作从源文件夹绘制的jar文件 - How to make jar files that draw from a source folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM