Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.4k points)

I want to package my project in a single executable JAR for distribution.

How can I make a Maven project package all dependency JARs into my output JAR?

1 Answer

0 votes
by (46k points)

After Creating your project execute this
 

<build>

 <plugins>

   <plugin>

     <artifactId>maven-assembly-plugin</artifactId>

     <configuration>

       <archive>

         <manifest>

           <mainClass>fully.qualified.MainClass</mainClass>

         </manifest>

       </archive>

       <descriptorRefs>

         <descriptorRef>jar-with-dependencies</descriptorRef>

       </descriptorRefs>

     </configuration>

   </plugin>

 </plugins>

</build>

with

mvn clean compile assembly:single

Also, make sure that compile goal is added before assembly:single else the code of your project won’t be included.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...