How to Install Java 17 on Red Hat Linux 9.3

How to Install Java 17 on Red Hat Linux 9.3

If you need to run Java applications on your Red Hat Linux 9.3 system, you’ll need to install a Java Runtime Environment (JRE) or the full Java Development Kit (JDK). In this guide, we’ll walk through the steps to install the latest Java 17 release on Red Hat Linux 9.3.

Prerequisites
Before we start, ensure you have root or sudo privileges to install packages on your system.

Enabling Third-Party Repositories
Red Hat Linux doesn’t include OpenJDK builds in the default repositories, so you’ll need to enable a third-party repository that provides OpenJDK packages. We’ll use the Red Hat Enterprise Linux (RHEL) 9 AppStream repository.

  1. Open the /etc/yum.repos.d/redhat.repo file in a text editor.
  2. Find the [rhel-9-for-x86_64-appstream-rpms] section and change the enabled option to 1.

[rhel-9-for-x86_64-appstream-rpms]
enabled=1

  1. Save and close the file.

Installing OpenJDK 17
With the AppStream repository enabled, you can now install OpenJDK 17 with the following command:

sudo dnf install java-17-openjdk

This will install the OpenJDK 17 package along with any dependencies.

Verifying the Installation
Once the installation completes, verify the installed Java version with:

java -version

You should see output similar to:

openjdk 17.0.x 2023-xx-xx
OpenJDK Runtime Environment (build 17.x.x+x)
OpenJDK 64-Bit Server VM (build 17.x.x+x, mixed mode, sharing)

Setting the JAVA_HOME Environment Variable
Many Java applications use the JAVA_HOME environment variable to determine the Java installation location. You can set it by editing your ~/.bashrc file:

  1. Open ~/.bashrc in a text editor.
  2. Add the following line, replacing /usr/lib/jvm/java-17-openjdk with the output from /usr/bin/javahome:
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
  1. Save and close the file, then run:
source ~/.bashrc

You’ve successfully installed Java 17 on your Red Hat Linux 9.3 system! You can now run Java applications that require this version.

Let me know if you need any clarification or have additional requirements for this blog post.

Leave a Reply

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


Translate ยป