0

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?

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91

1 Answers1

1

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.

Chris White
  • 29,949
  • 4
  • 71
  • 93
  • Does anything actually generate those jars within jars in the wild? From what I see, it looks like this unpacking logic is at least 5 years old, which seems a bit early for anticipating J8. – VoiceOfUnreason May 10 '12 at 14:47
  • http://stackoverflow.com/questions/2706222/create-cross-platform-java-swt-application - the top answer talks about Eclipse having a jar-in-jar classloader. Looks like the jar-in-jar is going to be deprecated in Cloudera 4 anyway -http://www.cloudera.com/blog/2011/01/how-to-include-third-party-libraries-in-your-map-reduce-job/ – Chris White May 10 '12 at 15:12