IntelliJ IDEA Ultimate comes with the out-of-the-box support for the most popular enterprise and open-source application servers, such as GlassFish, WebLogic, JBoss EAP, Wildfly, WebSphere, Tomcat, TomEE, Jetty, Geronimo, Resin and Virgo.
1. Application servers
To configure a server in the IDE, go to Settings → Application Servers and click the Add application server button. The IDE will automatically detect its version and will offer you to select which libraries to add to the dependencies when the server is used in the project.
2. Web facet
An important thing when you work with an application server is the 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 Project Structure → Modules and Project Structure → Facets.
Usually you don’t need to configure the 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 click to run the application via Run configurations. Each artifact has its name, type, output directory, layout and type (Web Application: Archive, Web Application: Exploded, EJB Application: Archive, EJB Application: Exploded, etc). To configure the artifacts, go to Project Structure → Artifacts.
If you use Maven or Gradle, you don’t need to configure the artifacts manually. The IDE automatically synchronize them with the artifacts defined in your build files.
4. Run configurations
A Run configuration defines how the artifacts are deployed to the server. IntelliJ IDEA has two types of Run configurations: Local and Remote. The Local Run configuration starts a new instance of the server and deploy artifacts there. The Remote configuration deploys the artifacts to a server which is already running standalone server.
Each application server may have different set of parameters in a Run configuration.
One the important parameters here is the On ‘update’ action, which defines how to update the application when you use the Update action via Ctrl+F10 (Cmd+F10 for Mac). Based on your choice the IDE can update resources, update classes and resources, redeploy or restart the server. Turn off the Show dialog checkbox if you don’t like to see the dialog each time you update the application. It’s a great time-saver when you update your application very frequently.
Another important parameter is the On frame deactivation, which defines how to update the application when you switch from the IDE, say to a browser. Based on the settings the IDE can update resources, update classes and resources or do nothing. This setting might 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 Exploded artifact type. For the Archive artifact type use the common HotSwap.
By default the IDE runs the application server using the project JRE. However you can always choose to use an alternative JRE.
The essential part of any Run configuration is the artifacts deploy.
By default the IDE automatically builds the artifacts before deploying. However you can change it using via the Before launch group in the Run configuration dialog.
A 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 Run configuration is created you can run or debug your application via the Toolbar, menu Run or the shortcuts: Run via Shift+F10, Debug via Shift+F9.
6. Update and HotSwap
The recommended way to apply changes in the code to a running application application is to use the Update action via Ctrl+F10 (Cmd+F10 for Mac). As it said above the Update action is only available for the Exploded artifact type. Based on your choice it can update resources or classes and resources. When the Update action is applied in the Debug mode it uses the HotSwap, otherwise it uses the Hot redeploy.
If you use the Archive artifact type you can only rely on the HotSwap, which is done automatically when you are in the Debug mode.
7. Build artifacts
You can always ask the IDE to build your artifacts on via the Build → Build artifacts action.
8. Application servers tool window
Each Run configuration is shown in the 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.