---
title: "How can I create an executable jar with dependencies using Maven?"  
description: "How can I create an executable jar with dependencies using Maven?"  
author: "Anonymous User"  
published: 2015-05-07  
updated: 2015-05-07  
canonical: https://www.mindstick.com/forum/23196/how-can-i-create-an-executable-jar-with-dependencies-using-maven  
category: "java"  
tags: ["java"]  
reading_time: 2 minutes  

---

# How can I create an executable jar with dependencies using Maven?

I have written a little [utility](https://www.mindstick.com/articles/12979/the-utility-of-accounting-tools-for-businesses-and-organizations) to run from the [command line](https://www.mindstick.com/forum/158085/how-do-i-pass-command-line-arguments-to-a-node-js-program) using Java. I want to [package](https://www.mindstick.com/blog/12619/tips-for-finding-the-right-package-when-you-buy-instagram-followers) it in a single executable jar for distribution (.jar [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp)).

How can I make [Maven](https://www.mindstick.com/forum/159220/how-can-i-create-an-executable-runnable-jar-with-dependencies-using-maven) package all [dependency](https://www.mindstick.com/interview/23013/what-is-dependency-resolution) jars into my jar?

## Replies

### Reply by Anonymous User

```
<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>
```

and you run it with\
mvn clean compile assembly:singleCompile goal should be added before assembly:single or otherwise the code on your own project is not included.\
See more details in comments.\
Commonly this goal is tied to a build phase to execute automatically. This ensures the JAR is built when executing mvn install or performing a deployment/release.

```
<plugin>  <artifactId>maven-assembly-plugin</artifactId>  <configuration>    <archive>      <manifest>        <mainClass>fully.qualified.MainClass</mainClass>      </manifest>    </archive>    <descriptorRefs>      <descriptorRef>jar-with-dependencies</descriptorRef>    </descriptorRefs>  </configuration>  <executions>    <execution>      <id>make-assembly</id> <!-- this is used for inheritance merges -->      <phase>package</phase> <!-- bind to the packaging phase -->      <goals>        <goal>single</goal>      </goals>    </execution>  </executions></plugin>
```


---

Original Source: https://www.mindstick.com/forum/23196/how-can-i-create-an-executable-jar-with-dependencies-using-maven

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
