Get JDK (Java SE Developerment Kit) 5 or higher from http://java.sun.com/javase/, if you are using Solaris, Linux, or Windows..
If you are using Mac OS X, you need to download JDK 5 (supported on Mac OS X 1.4 or later) from http://www.apple.com/support/downloads/java2se50release3.html and make JDK 5 the default JVM.
Download the GlassFish v2 distribution https://glassfish.dev.java.net/public/downloadsindex.html.
Set the environment variable JAVA_HOME to point to the directory in which JDK 5 is installed.
Run the following command:
java -Xmx256m -jar <filename>.jar
Set ANT_HOME to point to the ant 1.6.5 installation, which is at <downloaded-dir>/glassfish/lib/ant directory.
Navigate to the glassfish directory:
cd glassfish
If you do not want clustering capabilities, run the following command:
ant -f setup.xml