How to Setup Glassfish on Ubuntu or CentOs

How to install Glassfish on a virtual or dedicated server.

Note: # prompt is root and $ prompt is the user prompt

1- Upload JDK bin - preferably Oracle Sun JDK.

(be sure to get 32 or 64 based on what you using for your OS)

# cd /usr/# mkdir java# cd java# wget build.javapipe.net/files/jdk/jdk1.6.0_33-32bit.zip # unzip jdk1.6.0_33-32bit.zip

Note: If unzip does not work then do apt-get install unzip and try again.

2- Create symlink to simplify so that you can create path to it as /usr/java/jdk6

# ln -s jdk1.6.0_33 jdk6

3- Create user and home directory to host your tomcat and set shell to bash

# useradd -d /home/myapp -m myapp# chsh myapp -s /bin/bash

4- Change to user and set JAVA_HOME

# su - myapp $ nano .bashrc

Add the following at the end of the file:

## JAVA_HOME variables
JAVA_HOME=/usr/java/jdk6
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME

5- Save file then run following command to initialize.

$ . .bashrc

6- Test

$ java -version

You should get this output if it works:

java version "1.6.0_33"Java(TM) SE Runtime Environment (build 1.6.0_33-b04)Java HotSpot(TM) Client VM (build 20.8-b03, mixed mode)

7- Get Glassfish 3

$ wget http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1.zip

8- Unzip

$ unzip glassfish-3.0.1.zip

9- Start up your Glassfish to see if it works

Glassfish comes with domain1 already setup and ready to go. Use this for testing.

$ cd glassfishv3/glassfish/bin/$ ./startserv domain1

Use CTRL-C to cancel

10- Test your installation

Test by opening your browser and going to http://YOURIP:8080 and you should be greeted with the Glassfish welcome page.

You can start your application in the background using nohup:

nohup ./startserv domain1 2>&1 &
  • 210 Users Found This Useful
Was this answer helpful?

Related Articles

Spring Framework

Need to develop Plain Old JAVA Objects? Want to have fun developing your application? Then we...

Subdomain Handling Tutorial

This tutorial explains how you can host subdomains with JavaPipe's Tomcat hosting. This is...

Pointer Domain Handling Tutorial

This tutorial explains how you can host pointer domains with a Java web hosting package from...

Choosing between JBoss7's Standalone or Domain features.

JBoss 7 introduced new feature called managed domains. Basically this is a multi-server...

How do I restart my tomcat?

However, if you have a private Tomcat instance with a Java host like us, then you have the...