Creating a project
- Click Create New Project on the Welcome screen, or select File | New | Project. The New Project wizard opens.
2. In the left-hand pane, select Java Enterprise.
3. Specify the JDK that you are going to use (the Project SDK field): select one from the list, click New and select the JDK installation folder, or click Download JDK.
4. Specify your application server. (We’ll use Tomcat Server.) If Tomcat is not defined in IntelliJ IDEA yet, click New to the right of the Application Server field and select Tomcat Server.
In the Tomcat Server dialog, specify the Tomcat Server installation directory.
5. Under Additional Libraries and Frameworks, select the Web Application checkbox.
6. Specify the name for your new project
Click Finish and wait while IntelliJ IDEA is creating the project.
Exploring the project structure
When the project is created, you’ll see something similar to this in the Project tool window.
- JavaEEHelloWorld is a module folder (which in this case coincides with the project folder). The
.ideafolder and the file
JavaEEHelloWorld.imlcontain configuration data for your project and module respectively. The folder
srcis for your Java source code. The folder
webis for the web part of your application. At the moment this folder contains the deployment descriptor
WEB-INF/web.xmland the file
index.jspintended as a starting page of your application.
- External Libraries include your JDK and the JAR files for working with Tomcat.
Developing source code
Our application will be a single JSP page application. Its only function will be to output the text Hello, World!
index.jspfor editing: select the file in the Project tool window and press ⌘↓.
The code at this step is ready.
Running the application
In the upper-right part of the workspace, click ▶︎.
After that, the Run tool window opens. IntelliJ IDEA starts the server and deploys the artifact onto it.
Finally, your default web browser starts and you see the application output
Hello, World! there.
Modifying the code and observing the changes
2. In the Run tool window, click Update button
3. In the Update dialog, select Update resources and click OK. (For more information, see Application update options.)
4. Switch to the web browser and reload the page to see the changes.
See also, Updating Applications on Application Servers.
Exploring a run configuration
When creating the project, we specified Tomcat as an application server. As a result, IntelliJ IDEA created a run configuration for Tomcat.
When we performed the Run command (▶︎), we started that run configuration. Now let’s take a look at the run configuration and see how its settings map onto the events that we’ve just observed.
- Click the run configuration selector and select Edit Configurations.
The Run/Debug Configurations dialog opens and the settings for the Tomcat run configuration are shown.
The Before launch task list (in the lower part of the dialog) specifies that the application code should be compiled and the corresponding artifact should be built prior to executing the run configuration.
2. Select the Startup/Connection tab to see how the server is started in the run, debug and code coverage modes.
3. Select the Deployment tab to see which artifacts are deployed after the server is started.
4. Go back to the Server tab.
The settings under Open browser specify that after launch (i.e. after the server is started and the artifacts are deployed onto it) the default web browser should start and go to the specified URL (
The settings to the right of On ‘Update’ action specify that on clicking the reload button in the Run tool window the Update dialog should be shown and the Update resources option should be used by default. (The last used update option becomes the default one).
5. Click OK.
Exploring an artifact configuration
When creating the project, we indicated that we were going to develop a web application. As a result, IntelliJ IDEA, among other things, created a configuration for building a web application artifact. Let’s have a look at this configuration.
- Open the Project Structure dialog: File | Project Structure or
2. Under Project Settings, select Artifacts.
The available artifact configurations are shown in the pane to the right under + and –. (There’s only one configuration at the moment.)
The artifact settings are shown in the right-hand part of the dialog.
Type. The artifact type is Web Application: Exploded. This is a decompressed web application archive (WAR), a directory structure that is ready for deployment onto a web server.
Output directory. The artifact, when built, is placed into
Output Layout. The artifact structure is shown in the left-hand pane of the Output Layout tab.
<output root> corresponds to the output directory. Other elements have the following meanings:
- ‘JavaEEHelloWorld’ compile output represents compiled Java classes whose sources are located in the
srcdirectory. These are placed into
WEB-INF/classesin the output directory.
- ‘Web’ facet resources represent the contents of the