Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Note
iconfalse

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

New Project Wizard
span
classshortcut
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

New
span
classshortcut
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
classshortcut
Run
Edit Configurations
span
classshortcut
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

Finish
span
classshortcut
Wiki Markup
{span:class=shortcut}Finish{span}
, IntelliJ IDEA creates the project.

...

To make sure that libraries are properly configured, go to the

span
classshortcut
Project Structure
span
classshortcut
Modules
Project Dependencies
span
classshortcut
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
classshortcut
Project Structure
Facets
span
classshortcut
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
classshortcut
Project Structure
Artifacts
span
classshortcut
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
classshortcut
Run
Edit Configurations
span
classshortcut
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

Deployment
span
classshortcut
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

Live edit
span
classshortcut
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 Debug in Browser
span
classshortcut
Wiki Markup
{span:class=shortcut}Debug in Browser{span}
from the browser context menu.

...

When application is running, we can use the

Update
span
classshortcut
Wiki Markup
{span:class=shortcut}Update{span}
action via F10
span
classshortcut
Wiki Markup
{span:class=shortcut}F10{span}
to choose how to redeploy it.

...

Note that you can specify application redeployment settings on the

Update
span
classshortcut
Wiki Markup
{span:class=shortcut}Update{span}
tab, which is available in the Run configuration
span
classshortcut
Wiki Markup
{span:class=shortcut}Run configuration{span}
dialog.

One more useful option here is

On frame deactivation
span
classshortcut
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
classshortcut
Settings
Application Servers
span
classshortcut
Wiki Markup
{span:class=shortcut}Settings{span}
Wiki Markup
{span:class=shortcut}Application Servers{span}
.

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