384

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

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

Peter Mortensen's user avatar
Peter Mortensen
31.6k22 gold badges110 silver badges133 bronze badges
askedAug 14, 2012 at 6:42
Ashay Batwal's user avatar
2
  • 2
    I have also occasionally seen it called a "onejar" or "one-jar".CommentedDec 6, 2016 at 1:36
  • 2
    "uber" anything - unless in German, a concept named by an illiterate fool.CommentedJun 29, 2023 at 23:24

7 Answers7

518

Über is the German word forabove orover (it's actually cognate with the Englishover).

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 packageand 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 actuallyhas no dependencies.

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


(a) I probablyshouldn'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.

answeredAug 14, 2012 at 6:46
paxdiablo's user avatar
6
  • Strange... I am a german and of course know the word "über" and the meaning. But why is it used here in the Maven context? This case it means that one or more things are gathered together and is accessbile via the generated jar. Unfortunateley this hint didn't sovle my maven issue ;-)
    – Bjoern
    CommentedMar 5, 2015 at 18:09
  • 43
    BTW,über andover are the result of a systematic vocal shift in Old Germanic which can also be observed in these word pairs:geben/give,leben/live,haben/have,heben/heave and many more.CommentedJun 26, 2015 at 18:57
  • Very smart description: ExamplelinkCommentedDec 5, 2016 at 18:42
  • 1
    Given how much grief I've gotten about trying toeducate people, I've decided to just remove the stuff that some keep complaining about. I still define uber in the context of the German language but the (somewhat verbose) history lesson is now gone :-)CommentedFeb 20, 2020 at 13:32
  • 9
    Me: Reads "history lesson". Me: Opens revision history to read it. :-)CommentedJan 4, 2021 at 16:06
127

Fromimagej.net Uber-JAR description:

Anuber JAR file is also known asfat JAR, i.e., aJAR filewith dependencies.

There are three common methods for constructing an uber JAR file:

  1. Unshaded: Unpack all JAR files, and then repack them into a single JAR file. It works with Java's default class loader. Toolsmaven-assembly-plugin
  2. Shaded: Same as unshaded, but rename (i.e., "shade") allpackages of all dependencies. It works with Java's default class loader. It avoids some (not all) dependency version clashes. Toolsmaven-shade-plugin
  3. JAR files of JAR files: The final JAR file contains the other JAR files embedded within. It avoids dependency version clashes. Allresource files are preserved. Tools:Eclipse JAR File Exporter
blackgreen's user avatar
blackgreen
44.9k28 gold badges161 silver badges156 bronze badges
answeredAug 19, 2016 at 3:27
0
64

Paxdiablo's definition is really good.

In addition, please consider delivering an uber-jar is sometimes quite useful, if you really want to distribute a software and don't want customer to download dependencies by themselves. As a drawback, if their own policy don't allow usage of some library, or if they have to bind some extra-components (slf4j, system compliant libraries, architecture specialize libraries, ...) this will probably increase difficulties for them.

You can perform that:

A cleaner solution is to provide their library separately; maven-shade-plugin has a preconfigured descriptor for that. This is not more complicated to do (withMaven and its plugin).

Finally, a really good solution is to use anOSGi Bundle. There are plenty of good tutorials on that :)

For further configuration, please read those topics:

Peter Mortensen's user avatar
Peter Mortensen
31.6k22 gold badges110 silver badges133 bronze badges
answeredAug 14, 2012 at 14:12
Jean-Rémy Revy's user avatar
0
24

The different names are just ways of packaging Java applications.

Skinny – Containsonly the bits you literally type into your code editor, andnothing else.

Thin – Contains all of the aboveplus the application’s direct dependencies of your applications (database drivers, utility libraries, etc.).

Hollow – The inverse of thin. It contains only the bits needed to run your application, but doesnot contain the application itself. Basically a pre-packaged “app server” to which you can later deploy your application, in the same style as traditional Java EE application servers, but with important differences.

Fat/Uber – Contains the bit you literally write yourselfplus the direct dependencies of your applicationplus the bits needed to run your application “on its own”.

Source:Article from Dzone

Visual representation of JAR types

Reposted from:What is a fat JAR?

Peter Mortensen's user avatar
Peter Mortensen
31.6k22 gold badges110 silver badges133 bronze badges
answeredMay 18, 2020 at 17:11
Mark Han's user avatar
2
  • 'PLUS the bits needed to run your app “on its own”' Does that mean that I don't even need Java/JVM installed on the PC?
    – maribox
    CommentedDec 21, 2022 at 16:13
  • @MySurmise You still need to have Java/JVM/JRE installed.CommentedJun 21, 2023 at 1:18
4

A self-contained, executable Java archive. In the case of WildFly Swarm uberjars, it is a single .jar file containing your application, the portions of WildFly required to support it, an internal Maven repository of dependencies, plus a shim to bootstrap it all.see this

answeredMay 3, 2017 at 12:46
Rasheed's user avatar
1

According to uber-JAR Documentation Approaches:There are three common methods for constructing an uber-JAR:

Unshaded Unpack all JAR files, then repack them into a single JAR.Tools: Maven Assembly Plugin, Classworlds Uberjar

Shaded Same as unshaded, but rename (i.e., "shade") all packages of all dependencies.Tools: Maven Shade Plugin

JAR of JARs The final JAR file contains the other JAR files embedded within.Tools: Eclipse JAR File Exporter, One-JAR.

answeredJun 28, 2020 at 10:21
Md. Jamal Uddin's user avatar
1

For Java Developers who use SpringBoot,ÜBER/FAT JAR isnormally the final result of thepackage phase of maven (orbuild task if you usegradle).

Inside the Fat JAR one can find aMETA-INF directory inside which theMANIFEST.MF file lives with all the info regarding the Main class. More importantly, at the same level ofMETA-INF directory you find theBOOT-INF directory inside which the directorylib lives and contains all the.jar files that are the dependencies of your application.

answeredAug 22, 2020 at 18:49
Davide Martorana's user avatar
1
  • the same for gradleCommentedJul 17, 2023 at 13:58
Highly active question. Earn 10 reputation (not counting theassociation bonus) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.