Runnable Jar using Maven with dependancy

Maven is a great tool when it come to repetitive task. Exporting a runnable jar with maven can be done thanks to the maven-assembly-plugin

Edit your pom.xml file and add the plugin

<plugins>
    [...]
	<plugin>
    	<artifactId>maven-assembly-plugin</artifactId>
    	<configuration>
        	<archive>
            	<manifest>
                	<addClasspath>true</addClasspath>
                	<mainClass>com.yourcompany.yourMainClass</mainClass>
            	</manifest>
        	</archive>
        	<descriptorRefs>
            	<descriptorRef>jar-with-dependencies</descriptorRef>
        	</descriptorRefs>
    	</configuration>
    	<executions>
        	<execution>
            	<id>make-my-jar-with-dependencies</id>
            	<phase>package</phase>
            	<goals>
                	<goal>single</goal>
            	</goals>
        	</execution>
    	</executions>
	</plugin>
    [...]
</plugins>

Replace com.yourcompany.yourMainClass by the name of your entry point class who implement public static void main(String[] args)

Running the command “mvn clean install” will generate in the target/ directory a runnable call *YOUR_JAR_NAME*-jar-with-dependencies.jar who embed all it dependancy and the generated /META-INF/MANIFEST.MF file