Installing and running Eclipse, Glassfish and Ubuntu 12.04 Precise for Web Applications

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
javac -version

Now download the Java EE version of Eclipse:
Eclipse IDE for Java EE Developers
, 220 MB (linux 64 bit)

cd ~
tar -zxvf Downloads/eclipse-jee-juno-SR1-linux-gtk-x86_64.tar.gz

Create a nifty desktop icon:
cd ~/Desktop/
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-3.1.2.2.zip
cd ~
unzip Downloads/glassfish-3.1.2.2.zip
cd glassfish3/
bin/asadmin start-domain
bin/asadmin stop-domain

So now my home directory looks like this, since I extracted eclipse to it, and I unzipped glassfish to it:
ls ~/
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:
http://download.java.net/glassfish/eclipse/juno

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:

  • New/Servlet
  • 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)

About these ads

About SunKing2

Java programmer, connected web enthusiast, guitar player
This entry was posted in Uncategorized. Bookmark the permalink.

15 Responses to Installing and running Eclipse, Glassfish and Ubuntu 12.04 Precise for Web Applications

  1. Weisenheimer says:

    Hi, thanks for this great tutorial. I used it installing GlassFish4 and Eclipse Kepler. However, while creating the Servlet, I got a message “Specify class file destination”. I had to install a bunch of WDT packages (Help → Install new software… → Eclipse Kepler → Web Development) to get rid of it.

  2. Pingback: [non-original]Installing and running Eclipse, Glassfish and Ubuntu 12.04 Precise for Web Applications | hzhwine

  3. Dan Sol says:

    Very good, saved my night!

  4. german says:

    Nice article

  5. anthonykitmcinnis says:

    Hi, these instructions work perfect just as they are. I am grateful.

  6. Pingback: Ubuntu JPA With Eclipse | Connected Web

  7. jsinger says:

    Just completed it with Eclipse Juno and glassfish 3.1.2.2 on Ubuntu 12.10. Worked fine, thank you for this concise and really helpfull tutorial!

  8. Ranger Weng says:

    Very good guide. I deployed the glassfish with no difficulity following it. Thank you very much

  9. Anonymous says:

    I had to add a new Installed JRE in Eclipse preferences for java-7-openjdk-amd64 and then set the server JRE property for the open glassfish server to this new “JRE” otherwise is complains that glassfish needs a jdk but is was run as a jre.

  10. brunodouglas says:

    Worked like a charm! Just a question: looks like when you add GlassFish Extension on Eclipse it download the server again (all the 81MB), so if i’m just going to user the server studies and development it would be enougth to just add the extension on Eclipse, wouldn’t it?

    • SunKing2 says:

      yup, I think you are right

      • SunKing2 says:

        I added the full install of glassfish so that you have a full environment for testing outside of Eclipse. It also shows you how to correctly install glassfish, and shows you how to start it and stop it outside of Eclipse in case you ever need to (which if you work on it long enough you will), Thanks for mentioning that.

    • mjash says:

      Thanks for the primer SunKing2! I’m currently (2013jan11) having trouble with Eclipse (Juno) and the noted download site. I’m getting an “reading” error and Eclipse rolls back the install attempt. I found that you can install just the server adapters in another way. Window>>Preferences>>Server>>RuntimeEnvironment>>Add . In the new window click the “Download additional server adapters” link and once all are loaded, scroll to find the GlassFish adapter.

      • SunKing2 says:

        Eclipse can be quirky. What I do is reinstall eclipse. But this time in its own directory without using ubuntu’s software center or apt-get or anything. Just download eclipse from the eclipse site, and uncompress it into a directory in your home area. For example, create a directory /home/myusername/eclipse. Now uncompress it there. And you can start up eclipse by cd to that directory to find the executable to click on. I do this often. There’s nothing wrong with having 4 or 5 versions of eclipse on the same machine, and you tend to have more control over eclipse if you do it this way. It’s just a thought that might help… I’m no expert in all of Eclipse’s glitches.

  11. Pingback: Tab Sweep: Arquillian, Power Mac, PowerPC, JSP Performance, JMX Connection, … « oracle fusion identity

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s