Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To configure a server in the IDE, go to

span
classshortcut
Settings
span
classshortcut
Application Servers
and click the
span
classshortcut
Add application server
button. The IDE will automatically detect its version and offer you to select which libraries to add to the dependencies when the server is used in the project.

...

One important thing when working with an application server is the

span
classshortcut
Web facet
. This is where the IDE stores the web settings for each module of your project. These settings include the deployment descriptors and web resources roots, and are available in
span
classshortcut
Project Structure
span
classshortcut
Modules
and
span
classshortcut
Project Structure
span
classshortcut
Facets
.

Usually you don’t need to configure the

span
classshortcut
Web facet
manually. The IDE automatically detects the descriptors and web resource roots and offers to configure it.

...

An artifact is what the IDE deploys to a server when you run the application via

span
classshortcut
Run configurations
. Each artifact has its name, type, output directory, layout and type (
span
classshortcut
Web Application: Archive
,
span
classshortcut
Web Application: Exploded
,
span
classshortcut
EJB Application: Archive
,
span
classshortcut
EJB Application: Exploded
, etc). To configure the artifacts, go to
span
classshortcut
Project Structure
span
classshortcut
Artifacts
.

If you use

span
classshortcut
Maven
or
span
classshortcut
Gradle
, you don’t need to configure the artifacts manually. The IDE automatically synchronizes them with the artifacts defined in your build files.

4. Run configurations

A

span
classshortcut
Run configuration
defines how the artifacts are deployed to the server. IntelliJ IDEA has two types of Run configurations:
span
classshortcut
Local
and
span
classshortcut
Remote
. The Local Run
span
classshortcut
Local
run configuration starts a new instance of the server and deploy artifacts there. The
span
classshortcut
Remote
run configuration deploys the artifacts to an already running standalone server.

...

Each application server may have a different set of parameters in a

span
classshortcut
Run configuration
.

One important parameter here is

span
classshortcut
On ‘update’ action
, which defines how to update the application when you use the
span
classshortcut
Update
action via
span
classshortcut
Ctrl
+
span
classshortcut
F10
(
span
classshortcut
Cmd
+
span
classshortcut
F10
for Mac). Based on your choice, the IDE can
span
classshortcut
update resources
,
span
classshortcut
update classes and resources
, or
span
classshortcut
redeploy
or
span
classshortcut
restart the server
. Turn off the
span
classshortcut
Show dialog
checkbox if you don’t like to see the dialog each time you update the application. This is a great time-saver when you update your application very frequently.

Another important parameter is the

span
classshortcut
On frame deactivation
, which defines how to update the application when you switch from the IDE, say to a browser. Based on these settings, the IDE can
span
classshortcut
update resources
,
span
classshortcut
update classes and resources
, or
span
classshortcut
do nothing
. This setting may be very useful when you’d like to have your application updated automatically each time when you switch to a browser.

Keep in mind that update resources and update classes and resources options are available only for the

span
classshortcut
Exploded
artifact type. For the
span
classshortcut
Archive
artifact type use the common
span
classshortcut
HotSwap
.

By default, the IDE runs the application server using the project JRE. However, you can always choose to use an alternative JRE.

...

By default, the IDE automatically builds the artifacts before deploying. However you can change it using the

span
classshortcut
Before launch
group in the
span
classshortcut
Run configuration
dialog.

A Remote Run

span
classshortcut
Remote
run configuration has additional parameters such as the host/port of the server you’d like to deploy your artifacts to.

...

5. Run and debug application

Once a

span
classshortcut
Run configuration
is created, you can run or debug your application via the
span
classshortcut
Toolbar
, menu
span
classshortcut
Run
or the shortcuts:
span
classshortcut
Run
via
span
classshortcut
Shift
+
span
classshortcut
F10
,
span
classshortcut
Debug
via
span
classshortcut
Shift
+
span
classshortcut
F9
.

6. Update and HotSwap

When you need to apply changes in the code to a running application, we recommend using the

span
classshortcut
Update
action via
span
classshortcut
Ctrl
+
span
classshortcut
F10
(
span
classshortcut
Cmd
+
span
classshortcut
F10
for Mac). As mentioned above, the
span
classshortcut
Update
action is only available for the
span
classshortcut
Exploded
artifact type. Based on your choice, it can
span
classshortcut
update resources
or
span
classshortcut
update classes and resources
. When the
span
classshortcut
Update
action is applied in the
span
classshortcut
Debug
mode, it uses the
span
classshortcut
HotSwap
; otherwise, it uses the
span
classshortcut
Hot redeployment
.

If you use the

span
classshortcut
Archive
artifact type you can only rely on the
span
classshortcut
HotSwap
, which is done automatically when you are in the
span
classshortcut
Debug
mode.

7. Build artifacts

You can always ask the IDE to build your artifacts on via the

span
classshortcut
Build
span
classshortcut
Build artifacts
action.

8. Application servers tool window

Each

span
classshortcut
Run configuration
is shown in the
span
classshortcut
Application servers
tool window, along with the server and artifacts state. This tool window also helps you easily run/stop the server and deploy/undeploy/configure artifacts.

Image Removed

span
classshortcut
Run
/
span
classshortcut
Stop
the server and
span
classshortcut
Deploy
/
span
classshortcut
Undeploy
/
span
classshortcut
Configure
artifacts.

Image Added

Info
iconfalse

See also Getting Started with Java EE 7 and GlassFish 4.0 on how to create, configure, deploy and debug Java EE 7 application using GlassFish 4.0.