How to Install Java 17 on RHEL-based Linux Distributions

Java is a secure, stable, and well-known, general-purpose programming language and computing technology platform with many interconnected capabilities.

To run Java-based applications, you must have Java installed on your server. You mostly need the Java Runtime Environment (JRE), a collection of software components used to run Java applications on the Linux machine.

If you want to develop software applications for Java, you need to install the Oracle Java Development Kit (JDK), which comes with a complete JRE package with tools for developing, debugging, and monitoring Java applications and it is an Oracle’s supported Java SE (Standard Edition) version.

Note: If you are looking for an open-source and free JDK version, install the OpenJDK which provides the same features and performance as Oracle JDK under the GPL license.

In this article, we will show you how to install OpenJDK 16 from the EPEL repository and Oracle OpenJDK 17 (the latest release) using binary packages in RHEL-based Linux distributions such as CentOS, Fedora, Rocky Linux, and AlmaLinux to develop and run Java applications.

Install OpenJDK 16 in CentOS/RHEL and Fedora

At the time of writing this article, OpenJDK 16 is the currently available version to be installed using the following commands from the EPEL repository.

# yum install java-latest-openjdk
# java -version
Sample Output
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment 21.3 (build 16.0.1+9)
OpenJDK 64-Bit Server VM 21.3 (build 16.0.1+9, mixed mode, sharing)

Install Oracle OpenJDK 17 in CentOS/RHEL and Fedora

To install Oracle OpenJDK 17, you need to download the production-ready OpenJDK 17 from the Java SE Downloads page or run the following wget command to download and install it as shown.

# wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm

Install the package using the following command:

# yum localinstall jdk-17_linux-x64_bin.rpm

Next, confirm the installed Java version.

# java -version
java version "17.0.1" 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)

Set Default Java Version

If you have more than one Java version installed on the system, you need to set the default version using the alternatives command as shown.

# alternatives --config java
Sample Output
There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/java/jdk-17.0.1/bin/java
   2           java-latest-openjdk.x86_64 (/usr/lib/jvm/java-16-openjdk-16.0.1.0.9-3.rolling.el8.x86_64/bin/java)

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

Just, enter the number to set the default Java version on the system.

Finally, check the Java version.

# java -version
Sample Output
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment 21.3 (build 16.0.1+9)
OpenJDK 64-Bit Server VM 21.3 (build 16.0.1+9, mixed mode, sharing)

Congratulations! You’ve successfully installed the latest version of Oracle OpenJDK in RHEL, CentOS, Fedora, and Rocky Linux/AlmaLinux to develop and run Java applications.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

31 thoughts on “How to Install Java 17 on RHEL-based Linux Distributions”

  1. Is there something wrong with the Fedora package?

    After installing the package with rpm -Uvh jdk-7u25-linux-x64.rpm the following command would not list it:

    alternatives –config java

    Only shows one and that’s openjdk

    java -version gives me open jdk.

    Installing the package again (no errors or warnings the first time) tells me it already installed.

    I’ll try a reboot and see if that helps,.

    Reply
  2. Hi.. I’m very newbi to putty. Even I do not know the usage of linux machine.
    Now I want to learn
    How to install jdk in CentOS release 5.9 (Final) using putty ?
    Could plz. provide step by step procedure ?

    Thanks,
    Sadakar

    Reply

Leave a Reply to rishi Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.