Java is an open-source, powerful, and widely used programming language. It is used to build web-based applications, games, chatbots, enterprise applications, and more. It is cross-platform and can be run on all operating systems.
You will require an IDE on your system to develop Java applications. OpenJDK or Oracle JDK offers the Java package. Java JDK is a free, open-source, and powerful software development environment for developing Java Applications. JDK is a collection of programming tools, including Javac, JRE, Jar, and Java.
This post will show you how to install and manage different Java versions on Oracle Linux 10.
Install OpenJDK 25
When writing this article, the latest version of Java OpenJDK is version 18. The newest version is unavailable in the Oracle Linux 8 default repository, so you must install it from the source.
First, update your Operating System, and then download the latest version of OpenJDK from the Java official website:
dnf update -y
wget https://download.java.net/java/GA/jdk25.0.1/2fbf10d8c78e40bd87641c434705079d/8/GPL/openjdk-25.0.1_linux-x64_bin.tar.gz
Once the download is completed, extract the downloaded file with the following command:
tar -xvf openjdk-25.0.1_linux-x64_bin.tar.gz
Next, move the extracted directory to the /opt directory:
mv jdk-25.0.1 /opt/
Next, you must add the Java source path to the system environment. You can do it by creating the file java.sh:
nano /etc/profile.d/java.sh
Add the following lines:
export JAVA_HOME=/opt/jdk-25.0.1 export PATH=$PATH:$JAVA_HOME/bin
Save and close the file, then activate the Java path using the following command:
source /etc/profile.d/java.sh
Next, verify the Java path using the following command:
echo $JAVA_HOME
Sample output:
/opt/jdk-25.0.1
You can also verify the Java version using the following command:
java --version
You will get the following result:
openjdk 25.0.1 2025-10-21 OpenJDK Runtime Environment (build 25.0.1+8-27) OpenJDK 64-Bit Server VM (build 25.0.1+8-27, mixed mode, sharing)
Install OpenJDK 21
By default, OpenJDK 11 is available in the Oracle Linux default repository. You can install it using the following command:
dnf install java-21-openjdk-devel -y
Install Oracle JDK 25
When writing this article, the latest version of Oracle JDK is 18. 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:
Verifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:jdk-25-2000:25.0.1-8 ################################# [100%]
Next, verify the Java version using the following command:
java --version
Manage Java Versions
Java also allows you to install and manage multiple Java versions in the same system. You can use the “alternatives –config java” command to switch between various Java versions easily:
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.0.1-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.
Conclusion
This post explained how to install OpenJDK 25, 21, and Oracle JDK 25 on Oracle Linux 10. You also learned how to manage and switch between different Java versions. You can now start developing a Java application using your preferred Java version. Try it on dedicated hosting from Atlantic.Net!