Hello, friends. In this post, you will learn how to install Java 18 on Rocky Linux 9 / AlmaLinux 9. At the time of writing this post, we are in the presence of the latest stable version of Java.
We all know that Java is a very popular programming language and a mainstay of today’s technology. This language is used for many things, from desktop applications to applications like Jenkins that are used to deploy other applications. In other words, Java is essential and for many it is the gateway to programming.
This post is simple to do, but it can help developers to get a recent version of Java without too many problems.
Another thing to keep in mind is that you need to have access to the root user, or the
sudo command. So let’s get started.
Installing Java 18 on Rocky Linux 9 / AlmaLinux 9
Before you start, you will need to update the system completely
sudo dnf update
Java 18 is not in the official repositories of either of these two distributions. So, the most sensible option is to do a manual installation of the OpenJDK.
First, install these necessary packages:
sudo dnf install nano tar wget
Next, download the OpenJDK binary
Next, unzip the archive:
tar xvf openjdk-18.0.2_linux-x64_bin.tar.gz
Move the resulting folder to a more private location, such as
sudo mv jdk-18.0.2 /opt/
Now let’s add Java to the PATH:
sudo nano /etc/profile.d/jdk18.sh
And add the following content:
export JAVA_HOME=/opt/jdk-18.0.2 export PATH=$PATH:$JAVA_HOME/bin
Save the changes and close the editor.
To apply the changes, run:
And now you can check that java is installed:
java --version openjdk 18.0.2 2022-07-19 OpenJDK Runtime Environment (build 18.0.2+9-61) OpenJDK 64-Bit Server VM (build 18.0.2+9-61, mixed mode, sharing)
In this way, we will have a recent version of Java in the system thanks to the OpenJDK.
Java is a very popular programming language and therefore there are many installation methods. I invite you to check other posts about Java that we have on the post.