How to create executable jar with maven

This post explain you how to create executable jar file with maven.

Here i used maven-jar-plugin to create executable jar files. Please refer following pom.xml.

<project xmlns:xsi="" xmlns="" xsi:schemalocation="">




Change com.elitejavacoder.MainClass with your fully qualified class name of your main class.

Now build your project using mvn clean install command.

Check MANIFEST.MF file under the META-INF directory inside jar file. It should contain following entry.

Main-Class: com.elitejavacoder.MainClass (in your case fully qualified class name of your main class).

Now you can run this jar file using following command from command prompt.

java -jar commons-1.0.0-SNAPSHOT.jar