Install Java 17 (OpenJDK 17) on Oracle Linux 8

In our today’s guide, we are going to look at how to install Java 17 (OpenJDK 17) on Oracle Linux. What is java and what is it used for? Java is a programming language and a computing platform. You will find many powerful Enterprise applications written in Java. It is also required in our computers in order for some applications to run. Android applications are basically build with Java.

OpenJDK is the Java development environment. It is free to download and install. JDK 17 is the open-source reference implementation of version 17 of the Java SE Platform as specified by JSR 389. A significant number of Java Enhancement Proposals (JEPs) have been released in version 17 as listed below:

  • Restore Always-Strict Floating-Point Semantics
  • macOS/AArch64 Port
  • Enhanced Pseudo-Random Number Generators
  • New macOS Rendering Pipeline
  • Strongly Encapsulate JDK Internals
  • Deprecate the Applet API for Removal
  • Context-Specific Deserialization Filters
  • Pattern Matching for switch (Preview)
  • Remove RMI Activation
  • Remove the Experimental AOT and JIT Compiler
  • Sealed Classes
  • Foreign Function & Memory API (Incubator)
  • Deprecate the Security Manager for Removal
  • Vector API (Second Incubator)

Option 1: Install OpenJDK 17 on Oracle Linux 8

You can install OpenJDK 17 from OS default repositories.

sudo yum install java-17-openjdk java-17-openjdk-devel

After the installation confirm Java version.

$ java -version
java version "17.0.12" 2024-07-16 LTS
Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.12+8-LTS-286, mixed mode, sharing)

Option 2: Install Java SE 17 on Oracle Linux 8

If you wish to install Java SE Development Kit 17 instead, go ahead to download RPM package for Oracle Linux 8 from Oracle java download page. Download the rpm :

wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm

Then install it by running the below commands:

sudo rpm -Uvh jdk-17_linux-x64_bin.rpm

Now confirm Java installed version.

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

Configure Java environment.

sudo tee /etc/profile.d/jdk.sh <<EOF
export JAVA_HOME=/usr/java/default
export PATH=\$PATH:\$JAVA_HOME/bin
EOF

To use Java Home, source the file.

source /etc/profile.d/jdk.sh

Test Java Installation

To test our Java installation, let us create a simple html file. Create a file test.java with the content as shown below:

$ vi HelloWorld.java
public class HelloWorld {
	public static  void main(String[] args) {
	System.out.println(“Hello, world”);
	}
}

Compile Java code.

java HelloWorld.java

Now run your java program.

$ java HelloWorld
Hello, world

Set default Java Version

Run the command below to choose your default java version.

sudo alternatives –config java

Key in the number for your chosen version and press Enter

There is 1 program that provides 'java'.

Selection Command
-----------------------------------------------
*+ 1 /usr/java/jdk-17/bin/java

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

Explore More with CloudSpinx

Looking to streamline your tech stack? At CloudSpinx, we deliver the best solutions for your IT ventures.

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

Complete development environments can be constructed with the help of Vagrant. The “it works on my machine” justification is rendered […]

Virtualization is a technology that allows the creation of virtual instances or environments of computer hardware, operating systems, storage devices, […]

Zimbra Collaboration Suit (ZCS) is an open-source collaborative suite providing an email server and a web client. Among other services […]

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.