使用jarjarlinks仅包含jar中使用的类

时间:2023-01-13 16:08:52

I have an application that makes use of about 20 external jar files. In order to package everything up into a single file for distribution, I've been unjaring all the externals into a particular directory and then rejaring it all up into one jar. The end result is about 2MB in size. I want to use jarjarlinks to cut down the size of the distribution jar, but I can't find any examples on how to do what I want.

我有一个使用大约20个外部jar文件的应用程序。为了将所有内容打包到一个文件中进行分发,我一直在将所有外部内容解压缩到一个特定的目录中,然后将它们全部重新整理到一个jar中。最终结果是大约2MB。我想使用jarjarlinks来减少分发jar的大小,但我找不到任何关于如何做我想要的例子。

Essentially, I want to only take from the external jars, the classes that I am using and discard all the rest. Can jarjarlinks do that? If not, is there some other utility that anyone would recommend?

从本质上讲,我只想从外部罐子,我正在使用的类中取出并丢弃所有其余的。 jarjarlinks能做到吗?如果没有,是否有人会推荐其他实用程序?

My sources so far:

我的资料来源:

http://code.google.com/p/jarjar/wiki/GettingStarted

http://jonasboner.com/2005/12/09/stay-out-of-jar-hell-with-jar-jar-links.html

http://sixlegs.com/blog/java/dependency-killer.html

1 个解决方案

#1


0  

You could also use a tool called autojar.

您还可以使用名为autojar的工具。

Regarding the manifest file, you can add one with the -e option of the jar command once the jar is packaged:

关于清单文件,一旦打包jar,您可以使用jar命令的-e选项添加一个:

jar -uvfe myjar.jar full.name.of.class.with.main.method

#1


0  

You could also use a tool called autojar.

您还可以使用名为autojar的工具。

Regarding the manifest file, you can add one with the -e option of the jar command once the jar is packaged:

关于清单文件,一旦打包jar,您可以使用jar命令的-e选项添加一个:

jar -uvfe myjar.jar full.name.of.class.with.main.method