Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an uber jar?

I am reading Maven documentation and came across the name uber-jar.

What does an uber-jar mean and what are its features/advantages?

like image 291
Ashay Batwal Avatar asked Aug 14 '12 06:08

Ashay Batwal


People also ask

What is uber jar in AEM?

The AEM Uber jar includes all AEM APIs as a single dependency in your Maven project's pom. xml . It is always a best practice to include the Uber Jar as a single dependency instead of including individual AEM API dependencies.

What is spring boot uber jar?

The Uber JAR is a JAR where all of the application's compiled code along with the dependencies are grouped together so, that the programmer may find easy if he needs to deploy it somewhere as the dependencies come along with the JAR. The Uber JAR is also known as Fat JAR.

What is Superjar?

Utility to generate a single jar file containing all the resources referenced by a given jar file. As well as the contents of the named jar file itself, the contents of any jar files referenced in the Class-Path line of that file's Manifest will be included, and so on recursively.


2 Answers

Über is the German word for above or over (it's actually cognate with the English over).

Hence, in this context, an uber-jar is an "over-jar", one level up from a simple JAR (a), defined as one that contains both your package and all its dependencies in one single JAR file. The name can be thought to come from the same stable as ultrageek, superman, hyperspace, and metadata, which all have similar meanings of "beyond the normal".

The advantage is that you can distribute your uber-jar and not care at all whether or not dependencies are installed at the destination, as your uber-jar actually has no dependencies.

All the dependencies of your own stuff within the uber-jar are also within that uber-jar. As are all dependencies of those dependencies. And so on.


(a) I probably shouldn't have to explain what a JAR is to a Java developer but I'll include it for completeness. It's a Java archive, basically a single file that typically contains a number of Java class files along with associated metadata and resources.

like image 156
paxdiablo Avatar answered Sep 20 '22 19:09

paxdiablo


ubar jar is also known as fat jar i.e. jar with dependencies.
There are three common methods for constructing an uber jar:

  1. Unshaded: Unpack all JAR files, then repack them into a single JAR. Works with Java's default class loader. Tools maven-assembly-plugin
  2. Shaded: Same as unshaded, but rename (i.e., "shade") all packages of all dependencies. Works with Java's default class loader. Avoids some (not all) dependency version clashes. Tools maven-shade-plugin
  3. JAR of JARs: The final JAR file contains the other JAR files embedded within. Avoids dependency version clashes. All resource files are preserved. Tools: Eclipse JAR File Exporter

for more

like image 27
Premraj Avatar answered Sep 22 '22 19:09

Premraj