Install Java 21 (OpenJDK 21) on Oracle Linux 9|8

In this guide, we will look at how you can install Java 21 on Oracle Linux 9/8. Java is a widely adopted programming Language in businesses and personal projects alike. The latest version of Java available on Oracle Linux repository is Java 21. Java has a robust ecosystem and extensive libraries intended to simplify complex problem-solving among developers. With its huge developer community, Java has become a go-to language for building innovative, future-ready solutions.

OpenJDK is an open-source implementation of the Java Platform, Standard Edition licensed under the GNU General Public License version 2. The Oracle Linux AppStream repository contains the OpenJDK binaries from a fully open source set of build scripts and infrastructure.

Install Java 21 (OpenJDK 21) on Oracle Linux

Update your Oracle Linux machine to ensure you’re working with the latest releases of packages.

sudo dnf update

If you’re okay with the updates to be pushed to the system, accept with the y key.

....
Transaction Summary
=======================================================================================================================================================
Upgrade  11 Packages

Total download size: 25 M
Is this ok [y/N]: y

You can consider rebooting the system if there were kernel updates.

sudo systemctl reboot

You can get a list of Java 21 related packages on Oracle Linux using the command below.

$ sudo yum search java-21-openjdk
Last metadata expiration check: 0:34:32 ago on Mon 06 Jan 2025 10:34:16 AM UTC.
====================================== Name Exactly Matched: java-21-openjdk =======================================
java-21-openjdk.x86_64 : OpenJDK 21 Runtime Environment
========================================== Name Matched: java-21-openjdk ===========================================
java-21-openjdk-demo.x86_64 : OpenJDK 21 Demos
java-21-openjdk-devel.x86_64 : OpenJDK 21 Development Environment
java-21-openjdk-headless.x86_64 : OpenJDK 21 Headless Runtime Environment
java-21-openjdk-javadoc.x86_64 : OpenJDK 21 API documentation
java-21-openjdk-javadoc-zip.x86_64 : OpenJDK 21 API documentation compressed in a single archive
java-21-openjdk-jmods.x86_64 : JMods for OpenJDK 21
java-21-openjdk-src.x86_64 : OpenJDK 21 Source Bundle
java-21-openjdk-static-libs.x86_64 : OpenJDK 21 libraries for static linking

We will install java-21-openjdk package.

sudo dnf install java-21-openjdk

Dependency tree will be resolved automatically for you.

...                                                                    
Transaction Summary
=======================================================================================================================================================
Install  18 Packages

Total download size: 42 M
Installed size: 187 M
Is this ok [y/N]: y

Confirm Java 21 (OpenJDK 21) on Oracle Linux

Validate that Java was installed successfully on your Oracle Linux machine.

$ java -version
openjdk version "21.0.5" 2024-10-15 LTS
OpenJDK Runtime Environment (Red_Hat-21.0.5.0.11-1) (build 21.0.5+11-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.5.0.11-1) (build 21.0.5+11-LTS, mixed mode, sharing)

Write a test HelloWorld java application.

cat > Hello_World.java <<EOF
public class helloworld {
  public static void main(String[] args) {
    System.out.println("Hello Java World from CloudSpinx!");
  }
}
EOF

Execute the application.

$ java Hello_World.java
Hello Java World from CloudSpinx!

Yey!.. Seems Java 21 has been installed successfully on our Oracle Linux system.

Books For Learning Java programming:

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

Virtualization is the creation of a virtual version of something, this is achieved by allowing hardware components of a single […]

There are many programming languages available to use. They are used by developers as a way to build programs used […]

A database is a collection of structured data that is organized in such a way that can be easily accessed, […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.