Difference between extracting and packaging libraries into a jar file

If you want to put jars into your generated jar file, you can use packaging method. For example if you are using an Apache library or some other 3rd party jars, you may want to keep these jars preserved in your generated jar. In this case, use packaging. "Packaging required libraries into a jar file" option puts classes of org.eclipse.jdt.internal.jarinjarloader package into your generated file and this package is just under the root directory of the generated jar file. This option also creates a larger jar file in terms of size due to jar loader classes of Eclipse.

Extracting required libraries will result in putting classes of 3rd party libraries into your jar file by following the package naming convention, e.g. if you open your jar content you can see some classes under org.apache.. packages.

Main class entries are different between the MANIFEST.MF files of these jar files:

Main class entry when you package required libraries:

Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

Main class entry when you extract required libraries:

Main-Class: YourMainClass

For my use, the principal difference is that packaged JAR files are included intact as a distinct item, hence retaining their copyright information and signature data.

If you choose extract, the class files are pulled out of their original context and stored as if you had originated them, hence possibly violating some licence conditions, although the size of the final JAR will be smaller in this case. Eclipse does warn you about licensing in this case, too.

So, if using third-party JAR libraries, it's professional to always package.