Maven – Specify the default main class in the built jar using Manifest

We can set the default main class in the META-INF/MANIFEST.MF. This could be configured in the maven-jar-plugin in pom.xml. Let’s use the previous example.


1. Edit the pom.xml as follow.




2. So instead of specify the main class after the build…

  • java -cp .\target\testng-example-1.0.jar info.ykyuen.eureka.Addition 12 32


3. We can now just simply run the jar file.

  • java -jar .\target\testng-example-1.0.jar 12 32


Done =)

Reference: How do I specify a main class in the manifest of my generated jar file?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.