How to create a runnable JAR file with Maven?

By | November 1, 2020

In this post, We will learn How to create a runnable JAR file with Maven? 

Sometimes when We create a jar file, we want to execute it easily without using any IDE.

To create an executable jar File, we don’t need any additional dependencies. You just need to create a Maven project and have at minimum one class with the main(…) method.

In our example, we created a Java class named App.

We also need to make sure that our pom.xml contains the following elements:

Let’s try to understand the above concept using a Demo Project:


Now right-click on your project then go to Run As -> Maven build…

Provide Goals clean package and Click on Run

Once maven build completes then open the command prompt and move to the target directory after that type command java -jar First-Demo-Project-0.0.1-SNAPSHOT.jar and press Enter

That’s all about How to create a runnable JAR file with Maven?

You May Also Like:

How to create a multi-module project using maven?
How to Fix missing src/main/java & src/test/java folders in the Eclipse Maven web Project?
How to create user-defined properties in Maven?
What is the maven local repository location & how to change it?
How to add or update the maven settings.xml file in eclipse?
Importing maven remote Archetype Catalogs in eclipse ?
What is POM in the maven Project?
What is Super POM in Maven Project?
Understanding the purpose of Maven Plugin
Compiling the Maven project with different JDK versions? 
Understanding of settings.xml in maven
How to enable a proxy setting in Maven?
Maven Dependency Scopes
How to generate javadoc in the maven Project
How to add local jar files to a Maven project?
How to convert an existing Java Project to Maven in Eclipse?
How to exclude dependency in maven?
Managing External Dependencies in maven
Understanding of Maven Repositories
What is an archetype in Maven?
Snapshot Vs Version in maven
Apache Maven – Profiles

If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *