Note |
---|
|
This tutorial describes how to create, configure, deploy and debug Java EE 7 application using GlassFish 4.0 and IntelliJ IDEA 13. |
Wiki Markup |
---|
{redirect:https://www.jetbrains.com/idea/help/developing-a-java-ee-application.html|delay=0} |
1. Create new project
Create a Java application via
span |
---|
|
New Project Wizard Wiki Markup |
---|
{span:class=shortcut}New Project Wizard{span} |
.

2. Select application server
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 |
---|
|
New Wiki Markup |
---|
{span:class=shortcut}New{span} |
to configure one.

If you're going to deploy your application to multiple application servers, you can configure them later via
→ span |
---|
|
Edit Configurations Wiki Markup |
---|
{span:class=shortcut}Run{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Edit Configurations{span} |
.
3. Select JSF library
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.
...
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 |
---|
|
Finish Wiki Markup |
---|
{span:class=shortcut}Finish{span} |
, IntelliJ IDEA creates the project.
...
To make sure that libraries are properly configured, go to the
→ → span |
---|
|
Project Dependencies Wiki Markup |
---|
{span:class=shortcut}Project Structure{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Modules{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Project Dependencies{span} |
. There you can review and modify the list of libraries as you see fit.
...
To check the Web descriptor and resources directory configuration, go to
→ span |
---|
|
Facets Wiki Markup |
---|
{span:class=shortcut}Project Structure{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Facets{span} |
and configure descriptors (e.g. application server specific), or change Web resource directories.
...
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 |
---|
|
Artifacts Wiki Markup |
---|
{span:class=shortcut}Project Structure{span} |
→ Wiki Markup |
---|
{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 |
---|
|
Edit Configurations Wiki Markup |
---|
{span:class=shortcut}Run{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Edit Configurations{span} |
.
Run Configuration defines how application server is configured and controls application deployment.
...
10. Check artifacts to deploy
span |
---|
|
Deployment Wiki Markup |
---|
{span:class=shortcut}Deployment{span} |
tab lets you choose what artifacts to deploy, update or remove from application server when you run this configuration.
...
In addition to the server-side debugging toolsб IntelliJ IDEA provides the
span |
---|
|
Live edit Wiki Markup |
---|
{span:class=shortcut}Live edit{span} |
feature, which helps you debug applications directly in your Web browser. This is very simple, really: after you installed (
browser helper plugin), just use the
span |
---|
|
Debug in Browser Wiki Markup |
---|
{span:class=shortcut}Debug in Browser{span} |
from the browser context menu.
...
When application is running, we can use the
span |
---|
|
Update Wiki Markup |
---|
{span:class=shortcut}Update{span} |
action via
span |
---|
|
F10 Wiki Markup |
---|
{span:class=shortcut}F10{span} |
to choose how to redeploy it.
...
Note that you can specify application redeployment settings on the
span |
---|
|
Update Wiki Markup |
---|
{span:class=shortcut}Update{span} |
tab, which is available in the
span |
---|
|
Run configuration Wiki Markup |
---|
{span:class=shortcut}Run configuration{span} |
dialog.
One more useful option here is
span |
---|
|
On frame deactivation Wiki Markup |
---|
{span:class=shortcut}On frame deactivation{span} |
, which controls what happens when IntelliJ IDEA window loses focus. If you choose to redeploy resources at that moment, then, for example, switching from IntelliJ IDEA to Web browser would trigger this action, and by the time you hit Refresh, the application will already have been updated on server, allowing you to see all the changes you made in action much quicker than otherwise.
...
In this tutorial we used GlassFish 4.0. Of course, you can easily configure any other application server of your choice via
→ span |
---|
|
Application Servers Wiki Markup |
---|
{span:class=shortcut}Settings{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Application Servers{span} |
.

As we hope you can could see, development of Web Java EE applications with IntelliJ IDEA is easy as pie. And fun, too!