Getting Started With Java EE 8, Payara 5 and Eclipse Oxygen
Do you want to get a Java EE dev environment up quickly and painlessly? Let's look at getting it done with Payara and Eclipse IDE.
Join the DZone community and get the full member experience.Join For Free
Some days ago, I had the opportunity/obligation to set up a brand new Linux (Gentoo) development box, hence to make it "enjoyable," I prepared a back to basics tutorial on how to set up a working environment.
In order to set up a complete Java EE development box, you need at least a:
Working JDK installation and environment
Standalone application server if your focus is "monolithic"
Due to personal preferences, I choose:
OpenJDK on Gentoo Linux (Icedtea bin build)
Eclipse for Java EE developers
Since this is a distribution dependent step, you could follow tutorials on Ubuntu, CentOS, Debian and many more distributions if you need to. At this time, most application servers have Java 8 as their target due to the new Java-LTS version scheme, as in the case of Payara.
For Gentoo Linux, you could get a new OpenJDK setup by installing dev-java/icedtea for the source code version and dev-java/icedtea-bin for the precompiled version.
Is OpenJDK a Good Choice for My Needs?
Currently, Oracle has plans to free up all enterprise-commercial JDK features. In the near future, the differences between OracleJDK and OpenJDK should be zero.
In this line, Red Hat and other big players have been offering OpenJDK as the standard JDK in Linux distributions, working flawlessly for many enterprise-grade applications.
Eclipse for Java EE Developers
After a complete revamp of the website's GUI, you can go directly to eclipse.org and download Eclipse IDE.
Eclipse offers collections of plugins called Packages — each package is a collection of common plugins aimed for a particular development need. Hence to simplify the process, you could download Eclipse IDE for Java EE Developers.
On Linux, you will download a .tar.gz file, hence you should uncompress it in your preferred directory.
tar xzvf eclipse-jee-oxygen-3a-linux-gtk-x86_64.tar.gz
Finally, you could execute the IDE by entering the bin directory and launching the
cd eclipse/bin ./eclipse
The result should be a brand new Eclipse IDE.
You can grab a fresh copy of Payara by visiting the payara.fish website.
From Payara, you will receive a ZIP file that again you should uncompress in your preferred directory.
Finally, you could add Payara's bin directory to the PATH variable in order to use the
asadmin command from any CLI. You could achieve this by using a ~/.bashrc file. For example, if you installed Payara at ~/opt/, the complete instruction is:
echo "PATH=$PATH:~/opt/payara5/bin" >> ~/.bashrc
Integration between Eclipse and Payara
After unzipping Payara, you are ready to integrate the app server in your Eclipse IDE.
Recently and due to the Java/Jakarta EE transition, the Payara Team has prepared a new integration plugin compatible with Payara 5. In the past, you would also use Glassfish Developer Tools with Payara, but this is not possible anymore.
To install it, simply grab the following button on your Eclipse Window, and follow wizard steps.
In the final step, you will be required to restart Eclipse, after that you still need to add the application server. Go to the Servers tab and click create a new server:
Select the Payara application server:
Find Payara's install location and JDK location (corresponding to ~/opt/payara5 and /opt/icedtea-bin on my system):
Configure Payara's domain, user, and password.
In the end, you will have Payara server available for deployment:
Test the Femo Environment
It's time to give it a try. We could start a new application with a Java EE 8 archetype, one of my favorites is Adam Bien's javaee8-essentials-archetype, which provides you an opinionated essentials setup.
First, create a new project and select a new Maven Project:
In Maven's window, you could search, by name, any archetype in Maven Central, but you should wait a little bit for synchronization between Eclipse and Maven.
If waiting is not your thing, you could also add the archetype directly:
This archetype also creates a new JAX-RS application and endpoint. After some minor modifications, just deploy it to Payara 5 and see the results:
Published at DZone with permission of Víctor Orozco. See the original article here.
Opinions expressed by DZone contributors are their own.
Effective Java Collection Framework: Best Practices and Tips
How To Approach Java, Databases, and SQL [Video]
Competing Consumers With Spring Boot and Hazelcast