Java is a crucial programming language for many applications and services. If you’re running Oracle Linux and need to install the Java Development Kit (JDK), you’re in the right place. This guide will walk you through the process in a simple, straightforward manner. Whether you’re a beginner or an experienced Linux user, you’ll have Java up and running in no time.
Why Install Java JDK on Oracle Linux?
Oracle Linux is a popular enterprise-class Linux distribution, and many applications require Java to function properly. The Java JDK provides essential tools for developing and running Java applications, making it a must-have for developers and system administrators.
Step 1: Update Your System
Before installing Java, it’s always a good idea to update your system packages to ensure compatibility and security.
Open a terminal and run the following command:
sudo dnf update -y
This will refresh your system packages and install any necessary updates.
Step 2: Check if Java is Already Installed
Before proceeding with the installation, check if Java is already installed on your system:
java -version
If Java is installed, you’ll see output indicating the installed version. If not, you’ll see a message saying “command not found,” which means you need to install it.
Step 3: Install Java JDK
There are several ways to install Java JDK. For example, you may choose to install OpenJDK version instead of the Oracle Java JDK. But here, we will install the Oracle Java JDK. The version that I use here is version 23. Please visit the official download page for list of available editions.
To download, simply execute this command:
https://download.oracle.com/java/23/latest/jdk-23_linux-x64_bin.rpm
sudo dnf localinstall jdk-23_linux-x64_bin.rpm

Once completed, check using command:
java --version
It should show something like this:

Step 6: Set JAVA_HOME Environment Variable
Many applications require the JAVA_HOME
environment variable to be set. To do this we need to edit the .bashrc file.
nano ~/.bashrc
And then add the following lines:
JAVA_HOME=/usr/lib/jvm/jdk-23.0.2-oracle-xjava64
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
Make sure to edit this line : /usr/lib/jvm/jdk-23.0.2-oracle-x64 with your actual installation location.
Now close and save the file and finally execute this command
source ~/.bashrc
Conclusion
Congratulations! You’ve successfully installed Java JDK on Oracle Linux. Whether you’re using OpenJDK or the official Oracle JDK, you’re now ready to run Java applications and develop software.