In this article, we will have explained the necessary steps to install Java on Rocky Linux 8. Before continuing with this tutorial, make sure you are logged in as a user with
sudo privileges. All the commands in this tutorial should be run as a non-root user.
Java is the most popular programming language used to build many applications, systems, and high-level object-oriented programming language. Java runs on all major operating systems and devices.
Installing Java on Rocky Linux 8
Step 1. First, before you start installing any package on your Rocky Linux server, we always recommend making sure that all system packages are updated.
sudo dnf update sudo dnf upgrade sudo dnf install wget curl
Step 2. Install Java on the Rocky Linux system.
By default, Java does not come installed on Rocky Linux App stream, you will need to install these manually. Now download the OpenJDK version 16 from its official website using the following command:
curl -O https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_linux-x64_bin.tar.gz tar -xvf openjdk-16.0.2_linux-x64_bin.tar.gz
Then, move the extracted directory to the
mv jdk-16.0.2 /opt/
Next, add the Java path to the
Add the following content:
export JAVA_HOME=/opt/jdk-16.0.2 export PATH=$PATH:$JAVA_HOME/bin
Save and close the file also activate the Java with the following command below:
Java 16 is now installed. To confirm, use the following commands:
java version "16.0.4" 2021-09-01 Java(TM) SE Runtime Environment (build 16.0.4+7-67) Java HotSpot(TM) 64-Bit Server VM (build 16.0.4+7-67, mixed mode, sharing)
That’s all you need to do to install Java on Rocky Linux 8. I hope you find this quick tip helpful. For further reading on Install Java 16 (OpenJDK 16), please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.