Create Jakarta EE application using Maven

In this tutorial, I will guide you to create a new Jakarta EE application using Maven. You can use any Java IDE that supports Maven such as Eclipse, IntelliJ, .. or use the Maven command line!

I will use Eclipse in this tutorial.

First, in Eclipse, go to File, select New and then select Maven project:

Create web application using Maven in Eclipse

To create a Jakarta EE project with Maven, we will use Maven Archetype with Archetype for web application.

In the above window, we will not choose “Create a simple project (skip archetype selection)”, leave the default, and then click the Next button.

Create web application using Maven in Eclipse

This is the window that allows us to select the Maven Archetype. The Maven Archetype for Jakarta EE application is called maven-archetype-webapp so please choose it:

then click the Next button:

Create web application using Maven in Eclipse

This is the window that allows us to change the values of the Maven Group Id, Maven Artifact Id, Version, and also the package name.

I will fill in these values as follows:

Click Finish to complete.

During the process of creating a new project, you may see a command to confirm project information as follows:

Enter “Y” to confirm!

My result is as follows:

As you can see, our project is reporting an error.

The reason is that the default Maven Archetype that we are using does not declare the Jakarta EE Servlet API dependency in the pom.xml file:

so we need to do this.

Please open the pom.xml file and add this dependency:

with jakarta.jakartaee-api.version declared as follows:

As you can see, I also declared using Java 21, JUnit 5:

and the Maven Jetty Plugin:

to run our application.

The contents of my pom.xml file after editing are as follows:

The web.xml file also needs to be edited to match the Jakarta EE Servlet application, specifically as follows:

Result when running the application:

Add Comment