Install Java 11 (OpenJDK 11) on Rocky 8 | AlmaLinux 8

Java is a programming language and computing language platform. Java 11 is the open-source reference implementation of version 11 of the Java SE Platform as specified by JSR 388 in the Java community process. JDK is a collection of various programming tools among them are; JRE (Java Runtime Environment), Java, Javac, Jar e.t.c.

Java 11 has many features among them are:

  • Java 11 adds a few new methods to the String class
  • New File Methods
  • The Not Predicate Method
  • The new HTTP client from the java.net.http package
  • Local-Variable Syntax for Lambda
  • Nest Based Access Control
  • Improved Aarch64 Intrinsics
  • A No-Op Garbage Collector

This article demonstrates how to install Java 11 (OpenJDK 11) on Rocky Linux 8|AlmaLinux 8.

1) Install Java 11 (OpenJDK 11)

We will cover a few ways of how to get Java 11(OpenJDK 11) installed on Rocky Linux 8|AlmaLinux 8.

  1. OpenJDK
  2. Oracle JDK/JRE

Install OpenJDK 11 on Rocky Linux 8|AlmaLinux 8

Java Development Kit 11(JDK) is the open source reference implementation of version 11 of the Java SE platform. OpenJDK is available from RHEL 8 for x86_64 – AppStream (RPMs).

Option 1 – Install OpenJDK 11 from YUM repositories

To install Java 11 on Rocky Linux 8|AlmaLinux 8 from default upstream repositories run the commands below:

sudo yum install java-11-openjdk java-11-openjdk-devel

Confirm Java version:

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

Option 2 – Using Oracle JDK Binary

You can as well download manually using wget or curl command line tool:

sudo dnf -y install wget curl

Then download Oracle JDK 11 binary for your architecture.

Install the package on your system:

$ sudo rpm -Uvh jdk-11.*_linux-x64_bin.rpm
warning: jdk-11.0.25_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk-11-2000:11.0.25-ga           ################################# [100%]

Verify your Java installation.

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

2) Set the Default Java Version

With Multiple Java versions installed on Rocky Linux 8|AlmaLinux 8. You can set the default one as below.

First list the available versions:

sudo alternatives --config java

Sample output if your system has multiple versions:

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk-17/bin/java
 + 2           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.25.0.9-3.el9.x86_64/bin/java)

Enter to keep the current selection[+], or type selection number: 2

Select your version by typing the number as above.

Verify the Java 11 installation

With the default version set, go ahead and verify the version using:

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

3) Test Java Installation

Let us now test the installed Java by creating a simple html file with the below content.

vi HelloWorld.java 

In the file paste this:

public class helloworld {
  public static void main(String[] args) {
    System.out.println("Hello Java World from Kenya!");
  }
}

Compile and execute Java code.

$ java HelloWorld.java
Hello Java World from Kenya!

Conclusion

The article demonstrates how to install Java 11 (OpenJDK 11) on Rocky Linux 8|AlmaLinux 8. We have seen the two ways to get Java 11 installed on Rocky Linux | Alma Linux.

Explore More with CloudSpinx

Looking to streamline your tech stack? At CloudSpinx, we deliver robust solutions tailored to your needs.

Check out more articles:

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

PHP is a recursive acronym that stands for Hypertext Processor. It is a popular general-purpose scripting language used in web […]

We previously installed Asterisk LTS 18 on Rocky Linux 9 and we saw that it can only be administered from […]

In this blog post we will install Asterisk 18 with FreePBX on Rocky Linux / AlmaLinux 9. Asterisk is a […]

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.