A fat jar or uber jar is a jar that contains the classes of your current project as well as all of the classes on which it depends. For example, if your application requires
Joda-Time, your jar file will contain all the classes of your current project, as well as all the classes of Joda-Time. This helps solve the problem of having to organize and provide numerous jars for your program’s classpath.
Creating this fat jar with Maven is actually very easy. There are several plugins that do this, but my favorite is the Maven Shade Plugin. This opinion is mostly due to Maven Shade’s simplicity, community, and documentation. Creating a fat jar with Maven Shade can be as easy as adding the text below to the
pom.xml file in your Maven project.
By default, two jars will be created by executing the
package phase. The ‘original’ jar, which will only contain the classes of your current project, and the ‘shaded’ jar which will contain all of your projects dependencies.