Use the Maven Assembly Plugin - it will automatically build your JAR with all the dependencies included, and you can set the main class parameter to make the executable JAR file.
The documentation can be confusing, so here is an example of what your POM will look like:
<build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.1</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>package.of.my.MainClass</mainClass> <packageName>package.of.my</packageName> </manifest> </archive> </configuration> </plugin> </plugins> </build>
And then you can run as:
mvn assembly:assembly
source share