Create a new Java project using maven

Posted on Tuesday May 22, 2018 by Eric Potvin

Creating new Java project happens somehow often, but remember to add the pom.xml file is always something I forget. Of course, after creating this I will remember but in case you don't remember how or you do not know how here's two simple ways on how to create a Java project using maven:

  • The first method, (non geeky?) is using the UI
  • The second method, is by using the command line

The UI method

First, let's start by creating a new Project:

Name your project and location:

This creates the basic structure:

Adding Maven / pom.xml

Now, let's make this project a Maven project. Right click on the Project name in the "breadcrumb" section, then select "Add Framework Support..."

Select, Maven and click OK

Now we have a pom file that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""


This pom file needs some love!

Simply change the "groupId", "artifactId" and "version" tags, example:


At this point now you can create new files in the src/main folder and create some test that goes with it.

The Command line method

Another way to (very) easily build a maven project is using the command line tool.

mvn archetype:generate \ \
    -DartifactId=BookOfZeusApp \
    -DarchetypeArtifactId=maven-archetype-quickstart \

The "archetypeArtifactId" means what archetype to use to create the initial structure of the project

The interactiveMode means:
true if Maven should attempt to interact with the user for input, false if not. Defaults to true

This will create everything you need, including a sample script!


Notes: You might want to change the jUnit version from the pom.xml file.