We’ll use Eclipse, Glassfish and Java 7. I’ll show you how to install and get all of them running. Updated Dec. 2012 for Eclipse Juno.
On a fresh install of Ubuntu 12.04, do this:
sudo apt-get update
sudo apt-get upgrade
You absolutely need a JDK to run glassfish, I’m using Java 7:
sudo apt-get install openjdk-7-jdk
Now download the Java EE version of Eclipse:
Eclipse IDE for Java EE Developers, 220 MB (linux 64 bit)
tar -zxvf Downloads/eclipse-jee-juno-SR1-linux-gtk-x86_64.tar.gz
Create a nifty desktop icon:
ln -s ~/eclipse/eclipse eclipse
Start up Eclipse. Test it out with a quick project:
- create a New Project… (Java Project),
- 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 Community Downloads, and focus your attention to the top of that page. What we want is the “Not sure which version to use? Try the simple Zip archive” with the arrow beside it. It is a zip file.
If it asks what to do, save the file. Here’s what it put in my Downloads folder: glassfish-126.96.36.199.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)