How To Install GlassFish on Ubuntu 14.04

Install GlassFish on Ubuntu 14.04

In this tutorial, we will show you how to install GlassFish on Ubuntu 14.04. For those of you who didn’t know, GlassFish is a popular app server that can run java based web applications for you. GlassFish 4.1 release supports the latest Java Platform: Enterprise Edition 7. It supports Enterprise JavaBeans, JPA, JavaServer Faces, JMS, RMI, JavaServer Pages, servlets, etc.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you the step-by-step installation of GlassFish in the Ubuntu 14.04 server.


  • A server running one of the following operating systems: Ubuntu 14.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install GlassFish on Ubuntu 14.04

Step 1. First of all, make sure that all packages are up to date.

apt-get -y update

Step 2. Install Java JDK 8 on Ubuntu 14.04.

Verify Installed Java Version:

java -version


java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b25, mixed mode)

Step 3. Install GlassFish.

GlassFish should not run under root privileges, to run it as a non-root user we will create a user glassfish. If you wish to run glassfish as root simply skip this step and perform everything as root, however, I strongly discourage that. The user’s home directory will be the glassfish directory:

useradd glassfish
chown -R glassfish:glassfish /opt/glassfish4

Download the latest stable version of GlassFish, At the moment of writing this article it is version 4.1:

su - glassfish
rm -f

Create a init script for the GlassFish service:

nano /etc/init.d/glassfish

Add the following code lines:

# description: Startup script for Glassfish Application Server
# processname: glassfish


start() {
echo -n "Starting Glassfish: "
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
sleep 2
echo "done"

stop() {
echo -n "Stopping Glassfish: "
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
echo "done"

case "$1" in
echo $"Usage: glassfish {start|stop|restart}"

Make the ‘glassfish’ script executable:

chmod 755 /etc/init.d/glassfish

To start the GlassFish service daemon, use the following command:

### Start GlassFish ###
sudo /etc/init.d/glassfish start
### Stop GlassFish ###
sudo /etc/init.d/glassfish stop
### restart GlassFish ###
sudo /etc/init.d/glassfish restart

To turn the remote administration on and access the GlassFish admin console via web browser, execute the following commands:

cd /opt/glassfish4/glassfish/bin
./asadmin --user admin
asadmin> change-admin-password
./asadmin --host --port 4848 enable-secure-admin

Step 4. Accessing GlassFish.

GlassFish will be available on HTTP port 8080 by default also port 4848 by the administration. Open your favorite browser and navigate to or http://your-server-ip:4848 and complete the required steps to finish the installation. If you are using a firewall, please open ports 8080 and 4848 to enable access to the control panel.

Congratulations! You have successfully installed GlassFish. Thanks for using this tutorial for installing GlassFish on Ubuntu 14.04 system. For additional help or useful information, we recommend you to check the official GlassFish website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!




r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button