为什么RunJar解压缩jar文件? [英] Why does RunJar unpack the jar file?

查看:97
本文介绍了为什么RunJar解压缩jar文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

范例: http://grepcode.com/file/repository.cloudera.com/content/repositories/releases/com.cloudera.hadoop/hadoop-core/0.20。 2-320 / org / apache / hadoop / util / RunJar.java



我在查看RunJar.main(),并观察它解包指定的jar文件,然后从原始jar和本地分解副本中的几个根建立一个精心准备的类路径。



它是什么? Hadoop支持Jar吗?解决方案Hadoop支持Jar支持Jar吗?解决方案Hadoop支持Jar -in-jar(即jar文件在lib文件夹中的jar文件 - 不是很好!)。目前的Java版本都不支持jar-in-jar(我认为8支持这个,至少我认为我已经读过一些关于这个的抱怨,但是肯定不会引用我的话),这就是Hadoop实现了这一点。



为什么要在创建超级罐时创建jar-in-jar?构建时间可能是一个原因(拆包和重新包装巨大的depedant罐可能会增加几秒甚至几分钟到你的编译时间)。我相信还有更多,但对我来说,我认为生成的罐子是'更干净'的 - 我猜是个人喜好。


Example: http://grepcode.com/file/repository.cloudera.com/content/repositories/releases/com.cloudera.hadoop/hadoop-core/0.20.2-320/org/apache/hadoop/util/RunJar.java

I'm looking at RunJar.main(), and observing that it unpacks the specified jar file, then builds an elaborate class path from the original jar and several roots in the local exploded copy.

What's it for? What use case is supported by the exploded jar that isn't covered by including the original jar file alone?

解决方案

Hadoop supports Jar-in-jars (i.e. jar files in the lib folder in the jar file - mouthful isn't it!). None of the current Java versions support jar-in-jar (i think 8 is rumored to support this, at least i think i've read some grumblings about this, but certainly don't quote me on that), and this is how Hadoop achieves this.

Why would you want to do jar-in-jar when you could just created an uber-jar? Build time could be a reason (unpacking and repacking huge depedant jars could add seconds or even minutes to your build time). I'm sure there are more, but for me i think the resultant jar is 'cleaner' - personal preference i guess.

这篇关于为什么RunJar解压缩jar文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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