Share your love
Download and Install Oracle JDK 21 on Fedora 39
In this guide, you will learn to Download and Install Latest Oracle JDK Java 21 on Fedora 39. As you may know, Oracle Java also known as Oracle JDK is a popular implementation of the Java Platform. It will provide tools and libraries for developing Java applications. JDK 21 is the latest LTS version of the Java SE Platform. The binary packages are free to use and will receive updates until September 2026.
Now you can follow the steps below to Set up Oracle JDK 21 on Fedora Linux 39.
Steps To Download and Install Oracle JDK 21 on Fedora 39
To complete this guide, you must log in to your Fedora Linux as a non-root user with sudo privileges, then, follow the steps below to start your Oracle JDK installation.
Step 1 – Downloading Latest Oracle JDK Binary Package on Fedora 39
First, you must run the system update by using the command below:
sudo dnf update -y
Then, you must visit the Official website and get the latest RPM binary package which is JDK 21.
To do this, you can use the following wget command:
sudo wget https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.rpm
When your download is completed, you will get the following output:
Step 2 – Installing Oracle JDK 21 on Fedora 39
Then, you can use YUM or RPM to install your Oracle JDK 21 package. To do this, you can use the following command:
sudo rpm -Uvh jdk-21_linux-x64_bin.rpm
Once your installation is finished, you will see:
Next, you can verify your Java installation by checking its version:
java --version
Example Output:
Step 3 – Configure Java Environment Path on Fedora 39
At this point, you must configure the Java environment path on your server. To do this, you can use the following command:
cat <<EOF | sudo tee /etc/profile.d/jdk.sh
export JAVA_HOME=/usr/java/default
export PATH=\$PATH:\$JAVA_HOME/bin
EOF
Then, apply the changes by sourcing your file with the command below:
source /etc/profile.d/jdk.sh
Step 4 – Test Oracle JDK 21 is Working Correctly on Fedora
At this point, we want to create a sample Hello World project to see that Oracle JDK 21 is working correctly. To do this, you can create and open a file with your favorite text editor like Vi editor or Nano editor:
sudo vi HelloWorld.java
Add the following Java content to the file:
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
When you are done, save and close the file.
Then, compile and run your Java code with the following command:
sudo java HelloWorld.java
Output
Hello, World
As you can see, your JDK 21 is working correctly on your server. You can now start using your Oracle JDK.
Conclusion
At this point, you have learned to Download the latest Oracle Java RPM binary package and Install Oracle JDK 21 on Fedora Linux 39. Also, you have learned to test your Java installation by creating a sample project and start using it.
Hope you enjoy it. You may like to read the following articles:
Enable RPM Fusion Repository on Fedora 39
LAMP Stack Setup on Fedora 39 From Terminal