Payara for Beginners - Adding Payara Server to Eclipse IDE

04 Apr 2017

If you are creating a Java EE project, it is important to have a server defined in Eclipse so you can easily test your applications from the IDE - a much smoother workflow than building an artefact and manually deploying to Payara Server!

 

To add Payara Server to Eclipse, first make sure that you have Eclipse IDE for Java EE Developers installed. Add Payara Server using the following steps:

  1. Once you have the IDE loaded, open the Servers view by going to Window → Show View → Other:

1 - eclipse blog.png

 

2. Then select Servers from the menu:

 

2 - eclipse blog.png

 

3. Now that you have the servers view click the link to create a new server:

 

3 - eclipse blog.png

 

4. Since Payara Server is derived from GlassFish, we can select the GlassFish Tools in the server definition window.


If the tools are not already installed, select GlassFish Tools as the server type:

 

4 - eclipse blog.png

 

Eclipse will then download the tools that will allow it to connect to and recognise both GlassFish and Payara Server.

 

5. Once that has completed, restart Eclipse to make sure the tools are loaded, then     click the link to create a new server in the servers view again.


This time, choose GlassFish as the server type and specify the host name (localhost is fine for development use) and server name. The server name is simply an identifier you can use to differentiate between servers if you want to define a number of them; you may want to include the version in its name.

 

5 - eclipse blog.png

 

6. You must now specify the location of the glassfish directory within the Payara Server installation and your JDK home directory. In Linux, the JDK directories are under /usr/lib/jvm in most distributions.

 

6 - eclipse blog.png

 

7. Finally, specify the details of the domain that you are using. If you have not made any changes to your Payara Server configuration yet then the default values will be sufficient:

 

7 - eclipse blog.png

 

8. Payara Server is now ready for use with Eclipse. When creating a new Java EE project, set the target runtime to be Payara Server and to test an application choose Run on Server instead of Java Applet or Java Application:

 

8 - eclipse blog.png

 

9 - eclipse blog.png

 

Now that we can run applications on Payara Server without leaving the IDE, it's time to write some code! For inspiration, check out the Payara Examples repository on GitHub for some sample applications.

 

 

Payara Server Basics  Articles Series

 

 

Comments

Subscribe