1

Difference between extracting and packaging libraries into a jar file explains what happens if you select each option respectively.

What I don't understand is when one option would be recommended above the other.

Community
  • 1
  • 1
thegreatjedi
  • 2,788
  • 4
  • 28
  • 49
  • "Fat" Jars have the disadvantage that if you have resources within the same name space (across multiple Jars) they will collide. You also have to consider how the app might be updated. Is it really worth downloading the WHOLE app, when you can download separate Jars? If you're working in an environment, where different apps are using the same library Jars, it might be better have them maintained individually. When you factor in native wrappers, many of which can "include" the Jar's within them, a fat jar begins to lose it's appeal (IMHO) – MadProgrammer Jan 23 '17 at 07:18
  • Part of the problem with the question is it's opinion based. Some people just "like" fat jars, some don't, for no more reasons than that. You have to access your own personal pros and cons for your project and see what's best suited for you and the project generally – MadProgrammer Jan 23 '17 at 07:19
  • @MadProggrammer Thing is, I've never exported projects before. I know I don't want to "Copy required libraries into a sub-folder next to the generated JAR". As for the other two options, I can see what Eclipse does differently for each option from the other questions. What I don't understand is if there are functional differences in the end results of each option that would influence my decision. For example, when would an option not work? When would an option provide an advantage? And what advantage would it be? Preference is one thing, what about practical reasons? – thegreatjedi Jan 23 '17 at 07:23
  • I don't see a "massive" difference between the two. Admittedly, you're reading from a single file, rather the multiple files, so there "might" be a slight advantage, I've not bothered to benchmark it myself. If you're operating in a dynamic environment (loading Jars yourself), then a fat jar isn't much advantage. Equally, if you're using some kind meta-data lookup mechanism to configure parts of the app (coupled with dynamic class loading) then you'll have issues with a fat jar (as the resources well be overridden) – MadProgrammer Jan 23 '17 at 07:28

1 Answers1

0

Extract required libraries into JAR - Extracts the actual .class files from the libraries your app uses and puts those .class files inside the runnable JAR. So, the runnable JAR will not only contain the .class files of your application, but also the .class files of all the libraries your application uses. If the JARs are kept separate, then the user would only have to download the JAR that contains your application code, instead of a single, massive JAR that contains your application code and all the library code. if you update your application, then the user will have to download more data to update the application. 1)Package required libraries into JAR - Puts the actual JAR files of the libraries into your runnable JAR. Normally, a JAR file within a JAR file cannot be loaded by the JVM. But Eclipse adds special classes to the runnable JAR to make this possible. 2)Copy required libraries into sub folder next to JAR - Keeps the library JARs completely separate from the runnable JAR, so the runnable JAR will only contain the .class files of your application.

Sri
  • 1
  • 1
  • Everything you said can already be found in this website. What I want to know is when I should choose to extract required libraries, and when I should choose to package required libraries. I'm excluding the option to copy required libraries into a subfolder from the question. – thegreatjedi Jan 23 '17 at 07:09