Installing Glassfish in Eclipse

Glassfish is an open source Java EE compatible Application Server supported by Oracle with a number of features which make life easier for Java developers. We hope to look at some of those features in future posts, but today we’re going to walk through installing Glassfish on Linux Mint in Eclipse Kepler.

Glassfish is Part of the Java EE 7 JDK

The first thing to know is that Glassfish is part of the Oracle Java EE 7 JDK, which is where we start before Eclipse enters the picture. Go to the Oracle Java EE 7 SDK Downloads Page and select the package circled below.

Once downloaded we add Execute permissions to the .sh file and run it in a console. The complete install will look something like the following.

Here is the initial installation screen launched by the shell script.

As the wizard installs the JDK, go ahead and accept any default settings. You’ll want to remember the location of the Glassfish installation directory because you’ll be using it when configuring Glassfish in Eclipse.

A screen like this concludes the install.

Add the Glassfish Server to Eclipse

We’ll launch Eclipse when the Oracle Java JDK install completes and add our Glassfish server. We’ll start by creating a new server and downloading the Glassfish server adapter.

There it is, at the top of the list. Again, accept any default settings (blank admin password, for instance.) At the conclusion of the Glassfish service install you will be prompted to restart Eclipse.

Configuring Glassfish in Eclipse

This is where the process can get tricky. I mentioned before that you’ll need to remember the directory where you installed Glassfish. This is where you’ll be entering it, and notice the “/glassfish” subdirectory as the one you’ll enter in Eclipse (1).

And the tricky part, that “Glassfish server runtime requires full JDK instead of JRE” statement (2). Here we need to add the Oracle JDK runtime we just downloaded. We begin that process by clicking on the “Installed JRE preferences” link.

Adding the Java JDK Runtime

On the first screen we’ll select Standard VM.

On the second and final screen we enter the Oracle JDK EE 7 directory root, which by default is /usr/local/java/jdk1.7.0_45.

Now when we select the JDK on the New Server form the “Next” button is enabled and we’re good to go. The final screen (not shown) is adding Glassfish support for any existing projects in the current Workbench.

Testing the Glassfish Server

The Glassfish administrative Url is http://localhost:4848, so we’re going to fire that up to confirm our installation and configuration is complete.

We can also view any Console messages or Glassfish log files in Eclipse.

In future posts we’ll look at why Glassfish is handy for Java development, beginning with building JAX-WS Web Services.