This tutorial describes how to create, configure, deploy and debug Java EE 7 application using GlassFish 4.0 and IntelliJ IDEA 13. |
{redirect:https://www.jetbrains.com/idea/help/developing-a-java-ee-application.html|delay=0} |
Create a Java application via
{span:class=shortcut}New Project Wizard{span} |
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
{span:class=shortcut}New{span} |
If you're going to deploy your application to multiple application servers, you can configure them later via
{span:class=shortcut}Run{span} |
{span:class=shortcut}Edit Configurations{span} |
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
{span:class=shortcut}Finish{span} |
To make sure that libraries are properly configured, go to the
{span:class=shortcut}Project Structure{span} |
{span:class=shortcut}Modules{span} |
{span:class=shortcut}Project Dependencies{span} |
To check the Web descriptor and resources directory configuration, go to
{span:class=shortcut}Project Structure{span} |
{span:class=shortcut}Facets{span} |
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
{span:class=shortcut}Project Structure{span} |
{span:class=shortcut}Artifacts{span} |
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
{span:class=shortcut}Run{span} |
{span:class=shortcut}Edit Configurations{span} |
Run Configuration defines how application server is configured and controls application deployment.
{span:class=shortcut}Deployment{span} |
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
{span:class=shortcut}Live edit{span} |
{span:class=shortcut}Debug in Browser{span} |
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
{span:class=shortcut}Update{span} |
{span:class=shortcut}F10{span} |
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
{span:class=shortcut}Update{span} |
{span:class=shortcut}Run configuration{span} |
One more useful option here is
{span:class=shortcut}On frame deactivation{span} |
In this tutorial we used GlassFish 4.0. Of course, you can easily configure any other application server of your choice via
{span:class=shortcut}Settings{span} |
{span:class=shortcut}Application Servers{span} |
As we hope you could see, development of Java EE applications with IntelliJ IDEA is easy as pie. And fun, too!