如何合并两个 Jar 文件 [英] How to combine two Jar files

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

问题描述

是否可以组合两个 jar 文件,以便在 applet 标签中我可以简单地做类似的事情

Is it possible to combine two jar files such that in an applet tag I can simply do something like

archive="jarjar.jar/jar1.jar"...  ...archive="jarjar.jar/jar2.jar"... instead of
archive="jar1.jar"... ...archive="jar2.jar"...

我只需要一个 jar 文件,所以将两个 jar 文件放在一个文件夹中对我没有帮助.

I need to only have one jar file so putting two jar files in a folder will not help me.

推荐答案

当然,解压两个 jar 文件,重新创建一个新的

Sure, just extract the two jar files and recreate a new one

$ mkdir tmp
$ (cd tmp; unzip -uo ../jar1.jar)
$ (cd tmp; unzip -uo ../jar2.jar)
$ jar -cvf combined.jar -C tmp .

带有 tmp 的东西可确保将两个现有的 jar 提取到一个干净的目录中,然后从中提取新的 jar.

The stuff with tmp ensures that the two existing jars are extracted into a clean directory and then the new one made from that.

请注意,您可能还需要合并其中包含的任何 manifest.mf 文件,如果有的话,还需要在该文件命令中包含-m"选项.

Be aware that you may also need to merge any manifest.mf files contained therein, and if there are any also include the '-m' option in that file command.

这篇关于如何合并两个 Jar 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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