Home > Build-Management, Software Engineering > Create A Java Project With Maven

Create A Java Project With Maven

To create a Java Project from Maven Template open a terminal (*uix or Mac) or command prompt (Windows), navigate to the folder you want to store the project and call the following commands:

mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false


mvn archetype:generate -DgroupId=com.mycompany -DartifactId=MyMavenProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

To convert the Maven project to support Eclipse IDE, navigate to the project in terminal and call this command:

mvn eclipse:eclipse

The default JDK version is 1.4. If you want to update the POM, open the pom.xml file and add the compiler plugin to tell Maven which JDK version to compile your project:


You can also update the JUnit version to latest 4.11:


The Packaging with Maven can be done with the following command:

mvn package

It compiles, runs your tests and generates the project “jar” file in project/target folder.

To run the application call this command:

java -cp target/{project-name}-1.0-SNAPSHOT.jar {project-packaging}.{main-class}


java -cp target/MyMavenProject-1.0-SNAPSHOT.jar com.mycompany.App

With the jar plugin you can add a Manifest file to the jar.

java -jar target/MyMavenProject-1.0-SNAPSHOT.jar
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Connecting to %s