How To Install GlassFish on Ubuntu 22.04 LTS
In this tutorial, we will show you how to install GlassFish on Ubuntu 22.04 LTS. For those of you who didn’t know, GlassFish is a free, open-source software application server developed by Sun Microsystems (now Oracle). It implements technologies defined in the Java EE platform of this company and allows running apps that support this specification. It comes under two free software licenses Common Development and Distribution License and GNU General Public License.
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 and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the GlassFish on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
Prerequisites
- A server running one of the following operating systems: Ubuntu 22.04, 20.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 theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install GlassFish on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First, make sure that all your system packages are up-to-date by running the following apt
commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install software-properties-common apt-transport-https wget ca-certificates gnupg2 ubuntu-keyring
Step 2. Installing Java.
GlassFish is written in Java, now we install the Java OpenJDK and JRE to the Debian Buster 11. Both packages are available by default on the Ubuntu repository:
sudo apt install default-jdk default-jre
Once all installation is completed, check the Java version using the following command:
java -version
Step 3. Installing GlassFish on Ubuntu 22.04.
By default, GlassFish is available on Debian 11 base repository. So, now run the following command below to download the latest version of the GlassFish from the official page:
wget https://download.eclipse.org/ee4j/glassfish/glassfish-6.1.0.zip
Next, extract the downloaded file using the following command:
unzip glassfish-6.1.0.zip -d /opt/
Step 4. Setup GlassFish Systemd Service.
Now create a systemd
service file to manage the Glassfish service. You can create it with the following command:
nano /usr/lib/systemd/system/glassfish.service
Add the following lines:
[Unit] Description = GlassFish Server v6.1.0 After = syslog.target network.target [Service] User = root ExecStart = /usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar start-domain ExecStop = /usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar stop-domain ExecReload = /usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar restart-domain Type = forking [Install] WantedBy = multi-user.target
Save and close the file, then reload the systemd
daemon to apply the configuration:
sudo systemctl daemon-reload sudo systemctl enable glassfish sudo systemctl start glassfish
Step 5. Configure GlassFish on Ubuntu 22.04.
The default GlassFish admin password is blank. For more security, you can set a password for your GlassFish admin user. You can set it using the following command:
/opt/glassfish6/bin/asadmin --port 4848 change-admin-password
You will be asked to enter the admin password, press enter to set a new password:
Enter admin user name [default: admin]>admin Enter the admin password> Enter the new admin password> Enter the new admin password again>
Next, you will also need to enable a secure login:
/opt/glassfish6/bin/asadmin --port 4848 enable-secure-admin
Finally, restart the Glassfish service to apply the changes:
sudo systemctl restart glassfish
Step 6. Configure Firewall.
Ubuntu 22.04 has ufw
a firewall running by default. Enable connection through ports 4848 and 8080:
sudo ufw allow 4848 sudo ufw allow 8080 sudo ufw allow OpenSSH sudo ufw enable sudo ufw status
Step 7. Accessing GlassFish Web Interface.
Once successfully installed, open a web browser on your system and type the server’s IP in the address bar. You will get the default GlassFish page:
http://your-IP-addrees:4848/
Congratulations! You have successfully installed GlassFish. Thanks for using this tutorial for installing the GlassFish on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official GlassFish website.