Installation Wiki

Installing GlassFish

From InstallationWiki

Jump to: navigation, search
Installing GlassFish
Official Page
Project Documentation
Download
Source Book
Java EE 5 Development using GlassFish Application Server
Java EE 5 Development using GlassFish Application Server
ISBN 978-1-847192-60-8
Publisher Packt Publishing
Author(s) David Heffelfinger

Contents

[edit] Overview of Java EE and GlassFish

Java EE (formerly called J2EE) is a standard set of technologies for server-side Java development. Java EE technologies include Servlets, JavaServer Pages (JSPs), JavaServer Faces (JSF), Enterprise JavaBeans (EJBs), and the Java Messaging Service (JMS).

Several commercial and open-source application Java EE servers exist. Java EE application servers, such as GlassFish, allow application developers to develop and deploy Java EE-compliant applications. Other open-source Java EE application servers include Red Hat's JBoss, the Apache Software Foundation's Geronimo, and ObjectWeb's JOnAS.

Commercial application servers include BEA's Weblogic, IBM's Websphere, and the Oracle Application Server.

GlassFish is an open-source, freely available, Java EE application server. GlassFish is dual licensed under the Common Development and Distribution License (CDDL) and the GNU Public License (GPL) version 2.

To find out more about GlassFish's license, see https://glassfish.dev.java.net/public/CDDL+GPL.html.

Like all Java EE-compliant application servers, GlassFish provides the necessary libraries to allow us to develop and deploy Java applications compliant with Java EE specifications.

[edit] Obtaining GlassFish

GlassFish can be downloaded from https://glassfish.dev.java.net by clicking an image that looks like this:

The image should be near the top right window of the page.

After clicking on the image, and scrolling down to a section titled Binary builds around the middle of the resulting page, you should see links to download GlassFish for several different architectures. Currently Solaris Sparc, Solaris x86, Windows, Linux, and MacOS are supported.

To download GlassFish, simply click on the link for your platform; the file should start downloading immediately. After the file finishes downloading, you should have a file called something like glassfish-installer-v2-b58g.jar; the exact file name will depend on the exact GlassFish version and platform.

[edit] Installing GlassFish

Installing GlassFish is an easy process; however, GlassFish assumes that some dependencies are present in your system.

[edit] GlassFish Dependencies

Before GlassFish can be installed, a recent version of the Java Development Kit must be present in your system and (optionally) the Apache ANT tool.

  • Java Development Kit

In order to install GlassFish, a recent version of the Java Development Kit (JDK) must be installed on your workstation (JDK 1.5 or newer required), and the java executable must be in your system PATH. The latest JDK can be downloaded from http://java.sun.com/. Please refer to the JDK installation instructions for your particular platform at http://java.sun.com/javase/6/webnotes/install/ index.html.

  • ANT (Optional)

Ant is a very popular build tool; it can be downloaded from http://ant.apache.org. A version of ANT is included with GlassFish, therefore this step is optional. If you already have ANT installed on your system you can use it to install GlassFish. Just make sure that the ant script is executable and in your system's PATH. Please note that GlassFish requires ANT 1.6.5 or later.

[edit] Performing the Installation

Once the dependencies have been installed, copy the file downloaded in the previous section to an appropriate installation location and run the following command from a terminal window:

 java -Xmx256m -jar glassfish-installer-v2-b58g.jar

The actual file name at the end of the command will depend on the version of GlassFish downloaded.

After running this command, a window prompting you to accept the license terms will show up.

Scroll all the way down and click on the button labeled Accept.

You should see a lot of text scrolling on your terminal window, after the text stops scrolling, you should see the following text at the bottom of your terminal window:

 installation complete.

The installer creates a directory called glassfish at the location where we ran the above command from.

Although we saw the above message when we completed the step required in the previous paragraph, we are not quite done installing GlassFish. Inside the glassfish directory, there is an ANT build script that must be executed to complete the installation. The file name for this build script is setup.xml. This script can be executed from the command line by changing to the GlassFish installation directory and typing the following command:

 ant -f setup.xml 

(If you enter this in the dos mode and ant does not work, then try setting the system variable PATH (Windows Start>Control panel>system >advanced properties>system variables> if PATH does not fix it, try to give explicit path eg: c:\glassfish(if this is the install loaction)\lib\ant\bin -f c:\glassfish\setup.xml)

After executing this command you should see the following message at the bottom of the terminal the time taken may vary:

BUILD SUCCESSFUL

Total time: 43 seconds

The above command assumes that ANT 1.6.5 or newer is installed in the system, and that the ant executable is in the system PATH. GlassFish includes ANT; to access it from any directory add [glassfish installation directory]/glassfish/lib/ant/bin to your system PATH.


We have now successfully installed GlassFish and we are ready to start it for the first time.

[edit] Verifying the Installation

To start GlassFish, change directory to [glassfish installation directory]/ glassfish/bin, and execute the following command:

 ./asadmin start-domain domain1

The above command assume a Unix or Unix-like operating system. For Windows systems, the initial "./" is not necessary.

After executing the above command you should see a message similar to the following in the command line console:

Domain domain1 is ready to receive client requests. Additional services are being started in background.

The above message will be followed by additional information indicating the ports that GlassFish listens to and other information.

We can then open a browser window and type the following URL in the browser's location text field: http://localhost:8080.

If everything went well you should see a page similar to the following:

[edit] Getting Help

If any of the above steps fail, a good place to ask for help is the GlassFish forums at http://forums.java.net/jive/forum. jspa?forumID=56.

[edit] Source

The source of this content is Chapter 1:Getting Started with GlassFish of Java EE 5 Development using GlassFish Application Server by David Heffelfinger (Packt Publishing , 2007).