How to create runnable JAR file with Maven

How to create runnable JAR file using Maven assembly plugin.

By default if you run goal package, a JAR file will be created. But without dependencies and inside META-INF/MANIFEST.MF won't be specified Main-Class.


How to create a runnable Java application? Using Maven assembly plugin.

Add inside pom.xml file:


and then run goal:

 clean package assembly:single 

and inside target directory will be created a JAR file with packaged dependencies