What is an uber jar?

后端 未结 7 1225
旧时难觅i
旧时难觅i 2020-11-22 10:03

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

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

相关标签:
7条回答
  • 2020-11-22 10:06

    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 draw back, if their own policy don't allow usage of some library, or if they have to bind some extra-components (slf4j, system compliant libs, arch specialiez libs, ...) this will probably increase difficulties for them.

    You can perform that :

    • basically with maven-assembly-plugin
    • a bit more further with maven-shade-plugin

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

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

    For further configuration, please read those topics :

    • Should you provide dependent libraries in client jar?
    • Best practices in building and deploying Clojure applications: good tutorials?
    0 讨论(0)
  • 2020-11-22 10:13

    Ü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.

    0 讨论(0)
  • 2020-11-22 10:20

    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

    0 讨论(0)
  • 2020-11-22 10:21

    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.

    0 讨论(0)
  • 2020-11-22 10:29

    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

    0 讨论(0)
  • 2020-11-22 10:29

    The different names are just ways of packaging java apps.

    Skinny – Contains ONLY the bits you literally type into your code editor, and NOTHING else.

    Thin – Contains all of the above PLUS the app’s direct dependencies of your app (db drivers, utility libraries, etc).

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

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

    Source: Article from Dzone

    Reposted from: https://stackoverflow.com/a/57592130/9470346

    0 讨论(0)
提交回复
热议问题