How to create a new Java Project using Maven?

Do you want to be a successful Java developer? Here’s how to get started with Maven.

Introduction

In this post, I’ll share how to create a Java Maven project with the FREE highly popular IntelliJ Idea IDE in a matter of seconds.

New Project

Open IntelliJ Idea IDE and click on New Project.

Note that you can download the Free Community version which should be sufficient for most Java development.

image.png

image.png

In the New Project template, select Maven.

Archetypes

You can also create from archetypes such as Spring Sample or ReactJS.

image.png

For this quick example, we are not going to select any archetype.

Enter a name for your project and the GroupId.

image.png

By default, IntelliJ Idea creates projects in the IdeaProjects location. You can however choose another one.

POM

image.png

Once the project is created, you can see the POM file that contains your dependencies, configurations and plugins.

Using this IDE, there are several ways of installing third-party libraries such as Jackson or Scribe Java.

You can use maven goals or use the Search Artefact menu.

image.png

image.png

Build

image.png

You can then Build your project to see if anything breaks.

image.png

New Package

Add a new package. Should normally follow com.organisation.PackageName

image.png

Just for a quick example, Auth is enough.

image.png

Java Class

Create a new Java class.

image.png

The project's main entry point is the main method.

Click on the green arrow to launch the program.

image.png

“Hello World”

Creating a new Java project with Maven is straightforward and can be highly productive with the use of Archetypes.


Hi, my name is Abdallah. I'm a Senior Software Developer. I like sharing what I learn because I believe IT can improve people's quality of life. 🙂

Follow me for more tips on Software Development, Test Automation, Productivity and Problem Solving. 🚀