GlassFish is a free, open source and popular web application server started by Sun Microsystems that can be used to run java based web applications. GlassFish supports different Java based technologies like, JPA, JSF, JSP/Servlet, JMS, RMI, and many more. GlassFish provides simple and easy to use administration console with add-on components. It has very good support for high availability and load balancing.

In this tutorial, we will explain how to install GlassFish server on Ubuntu 18.04 server.


To follow this guide, you'll need a fresh installed Ubuntu 18.04 server, a regular, non-root user with sudo permission, enable a basic firewall to block non-essential ports with 2GB of memory.

When you have an account available, log in as your non-root user to begin.

Step 1 - Update The System

First, it is recommended to update your system packages to the latest version. You can update them using the following command:


sudo apt-get update -y sudo apt-get upgrade -y

Once all the packages are updated, restart your system to apply all the configuration changes.

Step 2 - Install Java

WildFly requires Java version 8 to be installed on your server. By default, Java 8 is not available in the Ubuntu 18.04 default repository. So, you will need to download it from their official website.

After downloading Java 8, extract it to the /usr/lib/jvm directory:


sudo mkdir /usr/lib/jvm/ sudo tar -zxvf jdk-8u221-linux-x64.tar.gz -C /usr/lib/jvm/

Next, set the Java default version with the following command:


sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_221/bin/java 1

Next, verify the Java with the following command:


java -version



java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

Step 3 - Install GlassFish

First, install some required dependencies with the following command:


sudo apt-get install software-properties-common wget unzip

Next, download the latest version of GlassFish with the following command:



Once downloaded, unzip the downloaded file to the /opt/ directory with the following command:


sudo unzip -d /opt/

Step 4 - Create a Systemd file for GlassFish

Next, you will need to create a systemd file to manage GlassFish service. You can create it with the following command:


sudo nano /etc/systemd/system/glassfish.service

Add the following lines:


[Unit] Description = GlassFish Server v5.0 After =

[Service] ExecStart=/opt/glassfish5/bin/asadmin start-domain ExecReload=/opt/glassfish5/bin/asadmin restart-domain ExecStop=/opt/glassfish5/bin/asadmin stop-domain Type = forking

[Install] WantedBy =

Save and close the file. Then, reload the systemd daemon with the following command:


sudo systemctl daemon-reload

Next, start GlassFish service and enable it to start on boot with the following command:


sudo systemctl start glassfish sudo systemctl enable glassfish

You can check the status of GlassFish service with the following command:


sudo systemctl status glassfish



● glassfish.service - GlassFish Server v5.0 Loaded: loaded (/etc/systemd/system/glassfish.service; disabled; vendor preset: enabled) Active: active (running) since Sat 2019-08-03 08:02:54 UTC; 22s ago Process: 15357 ExecStart=/opt/glassfish5/bin/asadmin start-domain (code=exited, status=0/SUCCESS) Main PID: 15380 (java) Tasks: 91 (limit: 1098) CGroup: /system.slice/glassfish.service └─15380 /usr/lib/jvm/jdk1.8.0_221/bin/java -cp /opt/glassfish5/glassfish/modules/glassfish.jar -XX:+UnlockDiagnosticVMOptions -XX:Ne

Aug 03 08:02:38 hitesh systemd[1]: Starting GlassFish Server v5.0... Aug 03 08:02:54 hitesh asadmin[15357]: Waiting for domain1 to start .............. Aug 03 08:02:54 hitesh asadmin[15357]: Successfully started the domain : domain1 Aug 03 08:02:54 hitesh asadmin[15357]: domain Location: /opt/glassfish5/glassfish/domains/domain1 Aug 03 08:02:54 hitesh asadmin[15357]: Log File: /opt/glassfish5/glassfish/domains/domain1/logs/server.log Aug 03 08:02:54 hitesh asadmin[15357]: Admin Port: 4848 Aug 03 08:02:54 hitesh asadmin[15357]: Command start-domain executed successfully. Aug 03 08:02:54 hitesh systemd[1]: Started GlassFish Server v5.0.

Step 5 - Access GlassFish

GlassFish is now installed and running, you can open GlassFish default page at http://your-server-ip:8080. You should see the following page: glassfish-default-page

To access the GlassFish admin interface, open your web browser and type the URL http://your-server-ip:4848. You will be redirected to the following page: glassfish-admin-onsole


Congratulations! you have successfully installed GlassFish on Ubuntu 18.04 server.

Read more about: Operating SystemUbuntu