Installing and configuring Glassfish Web Server

1- Introduction

This document is based on:
  • Glassfish 4.0

  • Cài đặt trên Window 7 (64 bit)

2- What is Glassfish Server

Glassfish Server is a webserver, allowing you to deploy web applications written on java. Like some other Webserver:
  • Tomcat
  • Weblogic
  • Websphere
  • JBoss
  • ....
You may be so familiar with Tomcat, a webserver serves for the purpose of studying and development applications. Glassfish developed by Sun is stronger than Tomcat. After Java part was sold to Oracle, Glassfish becomes the product of Oracle. Currently, Glassfish server has two version: a free version with open source code, and a commercial version.
In this document I will guide you to install and configure Glassfish free version.

3- Download

4- Start with Glassfish

Unzip Glassfish to specific folder on the hard drive:

Declare Java Home:

Glassfish4 requires you to use Java7 or newer. You need to declare the location of the Java:
Go to:
  • <Glassfish_Home>/glassfish/config
Edit File:
  • asenv.bat
Add configuration JAVA_HOME pointing to the location of your installation Java:
  • set JAVA_HOME=<Java_Location>

Run Glassfish

Open CMD and cd to:
  • <GlassFish_Home>/bin
Move to:
  • cd C:\glassfish-4.1\glassfish4\bin
To start domain1 on Glassfish server:
  • asadmin start-domain domain1
 To stop domain1:
  • asadmin stop-domain domain1
domain1 has been successful start.
Open URL:

Try deploying a web application:

You can download a demo web application at:
By default after being deployed, the application is run on port 8080. You can change to other port, or change to port 80. Configuration is discussed in detail below.

5- Other configurations

5.1- Change port 8080 to 80

5.2- Create Window Service for Glassfish Server

Open CMD as Administrator.
CD to bin folder of Glassfish:
Run command:

asadmin create-service --name domain1