将多个罐子合并成一个罐子 [英] Merging Multiple Jars in to a Single Jar

查看:27
本文介绍了将多个罐子合并成一个罐子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要多个 jars 才能工作.由于它是一个桌面应用程序,我不能让用户负责安装.因此,在我的构建脚本中,我将 jars 内容解压缩到我的构建目录中,删除清单文件,编译我的软件并再次对其进行 jar 包.一切正常,我的问题是这个过程是否有任何长期的副作用?

my application needs multiple jars to work. Since it is a desktop application i can not hold the user responsible of installing. So in my build script i unzip the jars content in to my build directory delete manifest files, compile my software and jar it again. Everything works as it should my question is are there any long term side effects to this process?

推荐答案

过去,有一些内容很奇怪的 JAR(比如包含 com.ibmcom.IBM;在 Windows 文件系统中解压后,这两个包将合并).

In the past, there were JARs with weird content (like the DB2 driver which contains com.ibm and com.IBM; after decompressing in a Windows filesystem, those two packages would be merged).

您需要注意的唯一问题是 META-INF 中的签名 jar 和其他文件,它们可能在多个源 JAR 中具有相同的名称.

The only issue you need to be aware of are signed jars and other files in META-INF which might have the same name in multiple source JARs.

解决所有这些问题的简单方法是使用 One-JAR.首先,它允许将多个 JAR 打包成一个而无需解压它们.并阅读这个答案:最简单的方法来合并一个发布到一个 JAR 文件中

A simple solution for all these issues is to use One-JAR. It allows to wrap several JARs into one without unpacking them, first. And read this answer: Easiest way to merge a release into one JAR file

这篇关于将多个罐子合并成一个罐子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆