We’ll use Eclipse, Glassfish and Java 9. I’ll show you how to install and get all of them running. Updated March 2016 for Ubuntu 16.04 and Eclipse Mars.
On a fresh install of Ubuntu 16.04, do this:
sudo apt-get update
sudo apt-get upgrade
You absolutely need a JDK to run glassfish, I’m using Java 9:
sudo apt-get install openjdk-9-jdk
Now download the Java EE version of Eclipse:
Eclipse IDE for Java EE Developers, 274 MB (linux 32 bit)
If it asks what to do, save the file to your Downloads folder.
tar -zxvf Downloads/eclipse-jee-mars-2-linux-gtk.tar.gz
Create a nifty desktop icon:
ln -s ~/eclipse/eclipse eclipse
Start up Eclipse. It may prompt you to select a workspace. I simply use the default, but I select “Use this as the default…”. When Eclipse starts, it shows a welcome tab, just close the tab.
Test Eclipse with a quick project:
- File/ New/ Project…/ Java Project (and create a project called Hello)
- create a HelloWorld.java and
- run it to ensure it works.
- Now right-click on the project and close project.
Now Glassfish. Go to Glassfish Downloads, and focus your attention to the Zip file for the FULL PLATFORM.
If it asks what to do, save the file. Here’s what it put in my Downloads folder: glassfish-188.8.131.52.zip
So now my home directory looks like this, since I extracted eclipse to it, and I unzipped glassfish to it:
Desktop Downloads examples.desktop Music Public Videos Documents eclipse glassfish3 Pictures Templates workspace
Now start up Eclipse. On the Help Menu, click Install new software. Click the Add button. Enter glassfish in the first box, and for the location enter:
It should present you with some options of software to install. Select the software related to the glassfish server, and let it install as per normal. When eclipse restarts, do the following (you may not have to):
window/Open Perspective/ Java EE
window/show view/ Servers
You should now see your Glassfish server magically appear in the servers list. We will now create a quicky servlet with a dumb lowercase name to help us later when running it:
- File/New/Dynamic Web Project
- Project Name: stuff / now click finish
Right-click on the project, and do:
- Class name: Complain
- leave all the defaults and click Finish
Yes Complain. you’ll see, once we create our GrouchyBean. But first let’s get a servlet running. Now right click on the project in the Project Explorer
- Run As/ Run on Server
- It should ask you which server and it should be very obvious to select glassfish
- Let it run. Once it starts running, a browser should appear and it should greet you with hello world.
This is not the servlet runnning, it’s just the JSP page that it created. The next step is in another article.
Could I ask you a tiny favor? Drop me a comment, and if you notice anything that could use a little improvement, I’ll try to be brave and make it better. Share the luv!
Here are the other articles:
- Ubuntu JPA and Eclipse with Derby
- How to create a Web Application using Ubuntu 12.04 Precise, Eclipse, and Glassfish
- Creating a simple EJB Enterprise JavaBean on Ubuntu 12.04 Precise
(Sorry, I know I haven’t had time to write them yet)