Install GlassFish 4.1 on Centos 7

install-glassfish-on-a-centos-7-vpsIn this tutorial, we will explain how to install GlassFish Server Open Source Edition 4.1 on a Centos 7.1 VPS. GlassFish is an open-source application server project and it’s Oracle’s concrete implementation of Java EE. This guide should work on other Linux VPS systems as well but was tested and written for a Centos 7 VPS.

1. Login to your VPS via SSH

ssh root@vps

2. Update the system and install necessary packages

[root]$ yum -y update
[root]$ yum install unzip wget

3. Create a new system user

Create a new user for the Glassfish server:

[root]$ adduser \
   --comment 'Glassfish User' \
   --home-dir /home/glassfish \

4. Install Oracle JDK 8

GlassFish 4.1 requires JDK 8 u20 or above. Use the command below to download the Oracle JDK 8 from the command line using wget:

[root]$ wget --no-cookies \
    --no-check-certificate \
    --header "Cookie: oraclelicense=accept-securebackup-cookie" \
    "" \
    -O jdk-8u45-linux-x64.rpm

Once the rpm package is downloaded, install it with:

[root]$ yum install jdk-8u45-linux-x64.rpm

To check if JAVA has been properly installed on your CentOS box run java -version, and the output should be similar to the following:

[root]$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

5. Download and extract the GlassFish 4.1 archive

Switch to the glassfish user:

[root]$ su - glassfish

As the glassfish user, download and extract the latest GlassFish 4.1 archive

[glassfish]$ wget
[glassfish]$ unzip
[glassfish]$ rm -f

Switch back to the root user:

[glassfish]$ exit

6. Create systemd service

To create a new systemd service for GlassFish, open your editor of choice and create a new file:

[root]$ nano /etc/systemd/system/glassfish.service

and add the following code lines:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer

Now just $43 .99

Description = GlassFish Server v4.1
After =

ExecStart = /usr/bin/java -jar /home/glassfish/glassfish4/glassfish/lib/client/appserver-cli.jar start-domain
ExecStop = /usr/bin/java -jar /home/glassfish/glassfish4/glassfish/lib/client/appserver-cli.jar stop-domain
ExecReload = /usr/bin/java -jar /home/glassfish/glassfish4/glassfish/lib/client/appserver-cli.jar restart-domain
Type = forking

WantedBy =

Start the glassfish server and set it to start automatically on boot:

systemctl enable glassfish.service
systemctl start glassfish.service

To verify the unit started, run journalctl -f -u glassfish.service and you should see something like below:

[root]$ journalctl -f -u glassfish.service
Apr 26 17:36:13 vps systemd[1]: Starting GlassFish Server v4.1...
Apr 26 17:36:19 vps java[2767]: Waiting for domain1 to start .....
Apr 26 17:36:19 vps java[2767]: Successfully started the domain : domain1
Apr 26 17:36:19 vps java[2767]: domain  Location: /home/glassfish/glassfish4/glassfish/domains/domain1
Apr 26 17:36:19 vps java[2767]: Log File: /home/glassfish/glassfish4/glassfish/domains/domain1/logs/server.log
Apr 26 17:36:19 vps java[2767]: Admin Port: 4848
Apr 26 17:36:19 vps java[2767]: Command start-domain executed successfully.
Apr 26 17:36:19 vps systemd[1]: Started GlassFish Server v4.1.

7. Firewall configuration

The default GlassFish port numbers are:

  • Administration: 4848
  • HTTP listener: 8080
  • HTTPS listener: 8181

For example to open port 8080 in the firewall, run:

firewall-cmd --zone=pubic --add-port=8080/tcp --permanent  
firewall-cmd --reload  

That’s it. You have successfully installed your GlassFish . For more information about GlassFish , please refer to the Glassfish website.

Of course you don’t have to Install GlassFish 4.1 on Centos 7,  if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately. You might also want to read our guide on How to Install GlassFish 5 on CentOS 7.

PS. If you liked this post, on how to Install GlassFish 4.1 on Centos 7,  please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

7 thoughts on “Install GlassFish 4.1 on Centos 7”

  1. Why new user is required for glassfish and you have not provided any set of permissions to that user then what is the need of creating a new user and install glassfish under that? Can it be installed under /opt or /usr/local?

  2. Job for glassfish.service failed because the control process exited with error code. See “systemctl status glassfish.service” and “journalctl -xe” for details.

    i has problem like that. But i can start with ./asadmin


Leave a Comment