5.1 Adding Tomcat to IDEA Ultimate

Step one. Create a local Tomcat configuration. Run-Edit Configurations-

Tomcat in IDEA Ultimate

Step two. Then select the local Tomcat.

Tomcat in IDEA Ultimate 2

Step three. Configuring Tomcat. By clicking on strong>configure add the path to the Tomcat folder

Tomcat in IDEA Ultimate 3

Here you can specify:

  • HTTP port- the port on which Tomcat will run
  • JRE- you can choose the JRE on which Tomcat will run
  • VM options- virtual machine settings for Tomcat
  • URL- this link will be opened by IDEA after starting the server with its help

Step four. We add our project as an artifact to Tomcat.

To do this, go to the Deployment tab and click the + button on the right.

Tomcat in IDEA Ultimate 4

That's all!

5.2 Creating the first web application

If you don't have any web application yet, then you can create it in IDEA in two ways. A Maven based project and just a native JavaEE project.

If you want to create a native web project from IDEA, then follow this simple instruction:

Step 1 . Create a new project ( menu File -> New Project), then select:

  • Project Type - Java Enterprise
  • Application template - Web Application
  • Application Server - The currently configured Tomcat Server . If it has not been added yet, then there is a button on the right New.
  • JDK - your current Java JDK
Tomcat in IDEA Ultimate 5

Step 2 . Further, IDEA will ask you to specify various dependencies, do not add anything.

Tomcat in IDEA Ultimate 6

Step 3 If Tomcat has been configured correctly, then you will see your application:

Tomcat in IDEA Ultimate 7

Step 4 Your project is ready, you can run it with the Run or Debug button.

5.3 Building Your First Maven Web Application

If you want to create a web application based on a Maven project, then the instructions will be even simpler.

Step 1 . Create a new project ( menu File -> New Project), then select:

  • Project Type - Maven Archetype
  • JDK - set the JDK of the project
  • Archetype (project template) - set maven-archetype-webapp
Maven based web application

Step 2 . We get a project like this:

Maven based web application 1

The project has been generated, but Tomcat has not yet been configured. To be able to run or debug a project, you need to set up Tomcat and add your project to it as an artifact. How exactly to do this, we have already considered earlier.

Step 3 If Tomcat is configured correctly, then your settings page should look something like this:

Maven 3 based web application

Step 4 Your project is ready, you can run it with the Run or Debug button.