This tutorial describes how to create, configure, deploy and debug Java EE 7 application using GlassFish 4.0 and IntelliJ IDEA 13.
Create a Java application via
|New Project Wizard|
Before you configure libraries, you need to select an application server to which you'll be deploying your application. If there is no application yet, click
If you're going to deploy your application to multiple application servers, you can configure them later via
If the application is using the JSF library, select the corresponding item in the list. By default IntelliJ IDEA uses libraries provided by the selected application server.
Library you selected is automatically downloaded and configured (if required), by IntelliJ IDEA.
Now you can select other libraries for use with your application: Bean Validation, CDI, JSON Processing, WebSockets, RESTful Web Services (JAX-RS), WebSockets, you name it.
After you click
To make sure that libraries are properly configured, go to the
To check the Web descriptor and resources directory configuration, go to
These settings will be used to build artifacts.
An artifact is what IntelliJ IDEA deploys to application server when you run your application. To make sure that artifacts are properly configured, go to
This dialog lets you change existing artifacts, or add new ones.
One last step before running the application is to make sure that its Run Configuration is all right. For that, see
Run Configuration defines how application server is configured and controls application deployment.
Assuming that everything is set right, we can try running our application.
When application is deployed to selected server, IntelliJ IDEA opens it start page (can also be changed in Run Configuration settings.)
In addition to the server-side debugging toolsб IntelliJ IDEA provides the
|Debug in Browser|
IntelliJ IDEA opens application page in your Web browser and warns that it's now available for live editing.
Now you can see the DOM structure of application page directly in IntelliJ IDEA, and, which is what's so cool about Live Edit, deploy them to the server as you type, so everything is synced without a single restart.
Try to make some changes on the page, and you'll see that browser displays them immediately.
Now let's create some server code and try debugging it.
When application is running, we can use the
In debug mode IntelliJ IDEA stops at breakpoints (well, what else would it do, right?)
Note that you can specify application redeployment settings on the
One more useful option here is
|On frame deactivation|
In this tutorial we used GlassFish 4.0. Of course, you can easily configure any other application server of your choice via
As we hope you can see, development of Web applications with IntelliJ IDEA is easy as pie. And fun, too!