A uber-jar is a mega jar that contains all the dependencies. It's usually also a runnable jar.
Here are the steps to create a uber-jar:
1) First of all you need a build section in your pom to make your jar runnable:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>uk.co.davisfiore.MainClass</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build>
2) Then you need to generate the uber file, running the following command:
mvn assembly:assembly -DdescriptorId=jar-with-dependencies
In output you should get something like this: my-project-0.0.1-SNAPSHOT-jar-with-dependencies.jar
3) Now you can run your jar without passing a long list of dependencies from command line:
java -jar myProject.jar
Copyright © 2013 Welcome to the website of Davis Fiore. All Rights Reserved.