Set Up Tomcat 11 and a Maven Web Project in IntelliJ IDEA
Set JAVA_HOME, install Tomcat 11 on a free port, create a Jakarta EE web application with Maven in IntelliJ IDEA, read its folders and pom.xml, and run it on Tomcat.
What you will learn
- Set JAVA_HOME on Windows so Tomcat can find Java
- Install Tomcat 11 on Windows, and know how to get it on Linux
- Create a Jakarta EE web application with Maven in IntelliJ IDEA
- Read the project layout and run the app on Tomcat with one click
Before you start
- Install Java 25 (JDK) and IntelliJ IDEA
- Maven basics
Before you can run a servlet or a JSP you need three things: Java that other tools can find, a servlet container (Tomcat 11), and a web project that builds into a .war. This article sets up all three on Windows and runs a Hello World page.
Step 1: set JAVA_HOME
Windows should know where Java lives, because Tomcat and other tools look for it through JAVA_HOME. There can be several JDKs on one machine, so first find the one IntelliJ uses: open any run configuration and look at the JDK list. On the lecture machine the path is under the user folder, in .jdks, a Microsoft build of JDK 25. Yours will be different.
- In Windows search, type system and open Edit the system environment variables.
- Click Environment Variables.
- Under System variables, click New. Name:
JAVA_HOME. Value: the path of your own JDK folder.
If your project folder lives in Google Drive, IntelliJ will also show a desktop.ini file in every folder. They are of no use in a project. Hide them in Settings > Editor > File Types > Ignored Files and Folders: click plus, type desktop.ini, then Apply.
Step 2: install Tomcat 11
Searching for Tomcat also turns up TomEE, which adds more of Jakarta EE on top. We want plain Tomcat (the difference is explained in Servlets and JSP: what Tomcat does).
- Go to
tomcat.apache.org, and under Download click Tomcat 11. In the recording the current version was 11.0.27. - Under Binary Distributions, take the Windows Service Installer and run it.
- Accept the licence. On the configuration page the HTTP connector port is 8080 by default. That port is popular and other programs often take it, so the lecture uses 9002. Any free port works. Keep the service name.
- The Java path is filled in from
JAVA_HOME. If it's empty, pick your JDK folder. - Keep the install folder under Program Files\Apache Software Foundation\Tomcat 11.0. A "folder is not empty" message only means an older Tomcat was there; click OK.
- At the end, untick Run Apache Tomcat and Show Readme. IntelliJ will start Tomcat for us.
On Linux or macOS there's no installer like this. Ask an AI assistant something like "how do I install Tomcat 11 on Ubuntu?" The answer is a short list of commands: install OpenJDK, check java -version, download the Tomcat archive with wget and extract it.
Step 3: create a Jakarta EE web project
- In IntelliJ, File > New > Project, and under Generators pick Jakarta EE.
- Name it
HelloWorld. Template: Web application. It comes with a servlet, aweb.xmland anindex.jsp. - Application server: the Tomcat you just installed. If it isn't listed, click New, choose Tomcat Server and point it at the Tomcat folder. TomEE and WildFly show up in the same list.
- Build system Maven, group
org.studyeasy, JDK 25. Click Next. - Version Jakarta EE 11, with only the Servlet dependency. Click Create and let Maven import the project.
The folder layout
HelloWorld
├── pom.xml
└── src/main
├── java/org/studyeasy/helloworld
│ └── HelloServlet.java
└── webapp
├── index.jsp
└── WEB-INF
└── web.xml
Java code goes under src/main/java. Pages go under src/main/webapp, with configuration in WEB-INF. At the root is pom.xml, Maven's file. Its key lines say the project is packaged as a war and depends on the servlet API:
<groupId>org.studyeasy</groupId>
<artifactId>HelloWorld</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.1.0</version>
<scope>provided</scope>
</dependency>
<!-- plus junit-jupiter-api and -engine with scope test -->
</dependencies>
The provided scope matters: Tomcat already has the servlet API, so Maven compiles against it but does not pack it into the war.
The generated servlet answers /hello-servlet, set by its annotation:
package org.studyeasy.helloworld;
import java.io.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;
@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {
private String message;
public void init() {
message = "Hello World!";
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/html");
// Hello
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<h1>" + message + "</h1>");
out.println("</body></html>");
}
public void destroy() {
}
}
Step 4: run it on Tomcat
With Tomcat set up, the run configuration at the top of IntelliJ shows Tomcat with a green run button. Click it.
- IntelliJ builds the project, and Tomcat starts in the Services window. You'll see it run
catalina.bat runfrom the Tomcat folder in Program Files. - Then: Artifact is deployed successfully. The war is on the server.
- The browser opens
localhost:9002/HelloWorld_war_exploded(the port picked during install) and shows Hello World fromindex.jsp. - The link on that page points to
/hello-servlet, the address the servlet answers.
Common mistakes
- Copying someone else's JDK path into
JAVA_HOME. Use the folder from your own machine. - Keeping port 8080 when another program already uses it. Tomcat fails to start; choose a free port.
- Picking TomEE or WildFly by accident in the server list. They work differently from the plain Tomcat used here.
- Looking for the page at
localhost:9002/. IntelliJ deploys under a context path such as/HelloWorld_war_exploded.
Quick recap
| Step | Result |
|---|---|
| JAVA_HOME | Tools can find your JDK |
| Tomcat 11 installer | Tomcat on a free port (9002 in the lecture) |
| Jakarta EE project | Maven web app packaged as a war |
| Run | Deployed to Tomcat, index.jsp in the browser |
With this running, move on to the servlet request lifecycle.
StudyEasy AI Community
Learn AI engineering, share what you build, and connect with other learners.
Free resources: lesson files, notebooks and code
Ask questions and join engineering discussions
Meet real people learning and building with AI
Related course on Udemy
FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE
Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)Related posts
Servlets and JSP: What a Servlet Container Does and How a JSP Becomes a Servlet
A JSP looks like HTML with a little Java, yet Tomcat runs it as a servlet. See what a servlet container does for each request, what the generated hello_jsp.java looks like, what a .war holds, and Tomcat vs TomEE.
The Servlet Request Lifecycle: @WebServlet, web.xml, init, doGet and destroy
A servlet is a Java class that answers a URL. Follow one request through Tomcat, map servlets with @WebServlet and web.xml, build a page from a list, and watch init, doGet and destroy run.
Servlet Request Parameters, and Forward vs Redirect
Read ?name=Emma with getParameter, then hand a request on two ways: a forward keeps one request and its attributes, a redirect makes the browser ask again and the attribute is gone.
Run a Java Web App in Docker: Tomcat 11 With One Compose Command
Run a servlet project without installing Tomcat: one docker compose command builds the WAR with Maven on Java 25, starts Tomcat 11 in a container, and serves the app on localhost:8090.
