Buy Support Online

Payara for Beginners - Adding Payara Server to IntelliJ IDEA

23 Mar 2017

When testing an app to be run on Payara Server, it can be extremely useful to be able to test your app continuously in your IDE (after all, that’s what it’s there for). If you're using IntelliJ IDEA, this is made very easy. Follow the steps in this blog to setup the Payara Server in IntelliJ for running your web apps.



If you already have a project setup and ready to deploy to Payara Server, then you can skip the first section. Otherwise, this section will quickly run through how to setup a project to test deploying to Payara Server.


Creating a Test Application with Maven

  1. First, click ‘create new project’ on the welcome screen to IntelliJ IDEA.

  2. Next, setup a Maven project from the archetype ‘maven-archetype-webapp’, as shown below. Make sure the project SDK points to the correct Java JDK you have installed.

IntelliJ Payara 1.png


3. After clicking next, enter an appropriate group ID, artifact ID and version. As this is just a test project, they don’t matter too much.


IntelliJ Payara 3.png


4. Click next through the rest of the screens, making sure the information is correct. Set a project name. For this example, I've named the project 'PayaraExample'. 


5. Congratulations, you’ve got your first web app setup ready for deploying to Payara Server!


Adding Payara Server to IntelliJ IDEA

Now you’ve got your project ready to deploy, you need to set a run configuration for your project. If you haven’t used a run configuration before - don’t worry, it’s just a way of defining how your projects can be run. You can have multiple run configurations for a project if it needs to be run in multiple ways. Follow these steps to make a run configuration for your project.

  1. Go to Run → Edit Configurations in the top menu.

  2. You’ll see the default run configurations on the left. Add a new configuration from the green plus in the top left.

  3. From the templates choose GlassFish Server → Local.
  4. In this window, you need to define an application server for IntelliJ IDEA. Click on 'Configure' next to the application server field.

IntelliJ Payara 3.png


5. In the configuration window, select the location of your 'payara41' directory. This is the place where you extracted Payara Server.
6. The application server field is now filled with 'GlassFish'. To change this, click on 'Configure' again, and enter the name of the server. For this, I've called it: 'Payara'. Click OK.
7. Set the name of the run configuration.
Since this is a mapping of the project 'PayaraExample' and Payara Server version, I've named the configuration: 'PayaraExample - Payara'.
8. There should be an error at the bottom of the window. This is correct, as we haven't defined a domain for using.
A domain always contains at least one server (the Domain Admin Server) which can be deployed to without any issues in development. For this example, I've used the default 'domain1'. Select this from the dropdown 'Server Domain'.
9. There should now be a new error. Don't worry, if you've followed the steps correctly nothing's gone wrong yet! The error means that the run configuration isn't running anything on the server, so it would just start and stop Payara Server without doing anything.
To fix this, go to the 'Deployment' tab at the top, and add a new artefact. Select the war file created from 'PayaraExample'. This will now build the project before deploying it to Payara Server.


IntelliJ Payara 4.png


 10. Check that the configuration now matches the one shown below.


IntelliJ Payara 5.png


11. The run configuration is now complete! All that's needed now is to run the project.


To run the project, go to the 'Run' menu at the top, and select "Run 'PayaraExample - Payara' ". You'll notice that this is the name of the run configuration you just made.

This should open a server console window at the bottom and start up the server. If everything is set up correctly, a 'Hello World' message should display in your browser!


IntelliJ Payara 6.png

( click image to enlarge)


To stop the server, either click the red square in the bottom left server window, or go to Run → Stop 'PayaraExample - Payara'.


That's all the steps required to run Payara Server in IntelliJ IDEA. You're now free to develop web applications for deploying to Payara Server!

Beginner's Guides to Payara Server






see all