GlassFish is an open-source Java EE application server of enterprise quality.
In this short article we’ll manually setup and go through the basics of GlassFish.
Step 1. Download
To download GlassFish go to glassfish community → Download → Scroll down the page → Binary builds → Windows Platform → glassfish-installer-v2ur2-b04-windows.jar
Step 2. Install
To install GlassFish run the jar file as follows
The -Xmx250m flag simply provides more memory to this operation.
A window appears with the CDDL licence agreement.
The installation process ends with a “installation complete” message on the command-prompt. Note that a folder glassfish is created.
Step 3. Setup
To setup GlassFish enter the glassfish folder and run the setup.xml script with ant.
This process should complete with a “BUILD SUCCESSFUL” message!
Step 4. Start
To start GlassFish use the powerful asadmin tool.
To verify check http://localhost:8080 where we can deploy our applications.
Once the server has started, a full-featured administrator console is available at http://localhost:4848.
Use admin as user and adminadmin as password.
The most valuable link for a developer is Home → documentation → Developer’s Guide.
At the left it’s the Application tree where we can see and deploy Enterprise Applications (.ear), Web Applications (.war) and EJB Modules (.jar).
Deploy an application
Here’s two ways to deploy a simple web application in GlassFish:
1. Accessing the hot-deploy folder
Simply put the application file in the autodeploy folder of the current domain, for example in
Note: The JBOSS users should not be suprised at all 🙂
That’s the same folder we should specify to tools like JDeveloper that handle packaging and deploying for us.
2. Using the admin console
Go to Applications → Web Applications → Deploy… → Location → Browse… → provide the path to the .war file → OK
At a glance
Let’s take a look inside the installation folder, for example inside
We see that GlassFish is bundled with JavaDB; a really cool database, written 100% in Java, used more than 10 years in production!
The bin folder has some useful tools, so it’s a good idea to put it in the PATH enviroment variable.
The domains folder contains independent server configurations. By default domain1 is available.
Inside a domain, the most important folders are autodeploy, where the applications are deployed, and config where various configuration takes place.
I agree with Marc Fleury that GlassFish looks the only application server capable of competing JBoss in the market. It’s slightly more tedious to install (GlassFish: 2 commands, JBoss: just unzip a file). However it’s as easy to use (hot-deploy) and it has a beautiful administrator console GUI (by the way it’s JSF).
All the action about GlassFish is at the glassfish community.
Also, Sun is offering a free introductory online course – for details see here.
Finally, for out-of-the-box development experience with GlassFish you may use the NetBeans IDE.