Table of Contents
Java is the most popular programming language used to build applications and systems. Additionally, you can use Java to create games, chatbots, enterprise applications, and more. Java can be run on all operating systems.
In order to develop Java applications, you will need to install an IDE on your system. It can be provided by OpenJDK or Oracle JDK. Java JDK is a free, open-source, and powerful software development environment used for developing Java Applications. JDK is a collection of programming tools including Javac, JRE, Jar, and Java.
In this post, we will show you how to install and manage different Java versions on Rocky Linux. This procedure is compatible with Rocky Linux 9 and Rocky Linux 10.
Install Java OpenJDK
In this section, we will show you how to install OpenJDK version 21, and 25 on Rocky Linux 10.
Install OpenJDK 21
At the time of writing this article, the latest version of Java OpenJDK is version 21. By default, the latest version is available in the Rocky Linux 10 default repository. You can install it using the below command.
dnf install java-21-openjdk-devel -y
You can verify the Java version using the following command:
java --version
You will get the following output:
java 21.0.8 2023-10-17 LTS Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29) Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)
Install Oracle JDK 25
At the time of writing this article, the latest version of Oracle JDK is 25. First, you will need to download it from its official website:
wget https://download.oracle.com/java/25/latest/jdk-25_linux-x64_bin.rpm
Once the download is completed, you can install it using the following command:
rpm -ivh jdk-25_linux-x64_bin.rpm
You will get the following output:
warning: jdk-25_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID 8d8b756f: NOKEY Verifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:jdk-25-2000:25-37 ################################# [100%]
Next, verify the Java version using the following command:
java --version
Sample output:
java 25 2025-09-16 LTS Java(TM) SE Runtime Environment (build 25+37-LTS-3491) Java HotSpot(TM) 64-Bit Server VM (build 25+37-LTS-3491, mixed mode, sharing)
Manage Java Versions
If you are using multiple Java versions in your project, then you can easily switch between them using the following command:
alternatives --config java
You will be asked to set the default Java versions as shown below:
There are 2 programs which provide 'java'. Selection Command ----------------------------------------------- 1 /usr/lib/jvm/java-21-openjdk/bin/java *+ 2 /usr/lib/jvm/jdk-25-oracle-x64/bin/java Enter to keep the current selection[+], or type selection number: 1
Select your preferred option and hit Enter to set the default Java version.
Next, verify your current Java version using the following command:
java -version
Sample output:
openjdk version "21.0.8" 2025-07-15 LTS OpenJDK Runtime Environment (Red_Hat-21.0.8.0.9-1) (build 21.0.8+9-LTS) OpenJDK 64-Bit Server VM (Red_Hat-21.0.8.0.9-1) (build 21.0.8+9-LTS, mixed mode, sharing)
Conclusion
In the above guide, you learned how to install OpenJDK 21, and Oracle JDK 25 on Rocky Linux 10. You also learned how to manage and switch between different Java versions. You can now easily install and manage your preferred Java version on your system. Get started on your virtual private server from Atlantic.Net!