Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make jar of jars using maven [duplicate]

Possible Duplicate:
Including dependencies in a jar with Maven

I am beginner in maven and would like to build a jar containing dependency jars in it using maven. But, I could not do so. Kindly help me about it.

like image 796
sridhar Avatar asked Jun 18 '12 10:06

sridhar


People also ask

How do I create an executable jar from maven?

In order to compile the project into an executable jar, please run Maven with mvn clean package command.

Can A jar contains other JARs?

To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes. For example, if MyJar. jar contains another JAR file called MyUtils. jar, you cannot use the Class-Path header in MyJar.


1 Answers

If you're trying to create a single jar that contains your application and it's required libraries, there are two ways (that I know of) to do that. The first is One-Jar, which uses a special classloader to allow the nesting of jars. The second is UberJar, (or Shade), which explodes the included libraries and puts all the classes in the top-level jar.

I should also mention that UberJar and Shade are plugins for Maven1 and Maven2 respectively. As mentioned below, you can also use the assembly plugin (which in reality is much more powerful, but much harder to properly configure).

like image 52
Hip Hip Array Avatar answered Sep 29 '22 19:09

Hip Hip Array