Java Runtime Environment (JRE) provides the necessary components to run Java applications on your systems. A JRE includes the Java Virtual Machine (JVM), the Java class libraries, and other supporting files.

JRE is available both from OpenJDK and Oracle. OpenJDK JRE is an open-source implementation of the Java SE platform, while Oracle JRE is the official version by Oracle. Both versions are similar, but Oracle JRE may have some additional features unavailable in OpenJDK JRE. This guide will show you how to install OpenJDK's JRE on CentOS, Red Hat, and Fedora.

OpenJDK's JRE can be installed using yum or dnf at the terminal on these Linux distributions. You can also choose from multiple versions of OpenJDK's JRE available in the default yum repositories.

Steps to install Java Runtime Environment (JRE) on CentOS, Fedora and Red Hat:

  1. Launch terminal.
  2. Search for available JRE versions for your distribution and version.

    $ dnf search openjdk | grep Runtime
    Last metadata expiration check: 0:07:34 ago on Thu 26 Jan 2023 09:51:16 AM +08.
    java-1.8.0-openjdk.aarch64 : OpenJDK 8 Runtime Environment
    java-1.8.0-openjdk-headless.aarch64 : OpenJDK 8 Headless Runtime Environment
    java-11-openjdk.aarch64 : OpenJDK 11 Runtime Environment
    java-11-openjdk-headless.aarch64 : OpenJDK 11 Headless Runtime Environment
    java-17-openjdk.aarch64 : OpenJDK 17 Runtime Environment
    java-17-openjdk-headless.aarch64 : OpenJDK 17 Headless Runtime Environment
  3. Install preferred OpenJDK's JRE version from official repository.

    $ sudo dnf install --assumeyes java-17-openjdk
    [sudo] password for user: 
    Last metadata expiration check: 1:58:16 ago on Thu 26 Jan 2023 10:27:45 AM +08.
    Dependencies resolved.
    ================================================================================
     Package                   Arch     Version                    Repository  Size
    ================================================================================
    Installing:
     java-17-openjdk           aarch64  1:17.0.6.0.9-0.3.ea.el9    appstream  430 k
    Installing dependencies:
     copy-jdk-configs          noarch   4.0-3.el9                  appstream   28 k
     java-17-openjdk-headless  aarch64  1:17.0.6.0.9-0.3.ea.el9    appstream   41 M
     javapackages-filesystem   noarch   6.0.0-3.el9                appstream   14 k
     lksctp-tools              aarch64  1.0.19-2.el9               baseos      93 k
     lua                       aarch64  5.4.2-7.el9                appstream  185 k
     lua-posix                 aarch64  35.0-8.el9                 appstream  149 k
     mkfontscale               aarch64  1.2.1-3.el9                appstream   32 k
     ttmkfdir                  aarch64  3.0.9-65.el9               appstream   51 k
     tzdata-java               noarch   2022g-2.el9                appstream  229 k
     xorg-x11-fonts-Type1      noarch   7.5-33.el9                 appstream  505 k
    
    Transaction Summary
    ================================================================================
    Install  11 Packages
    
    Total download size: 43 M
    Installed size: 200 M
    ##### snipped
  4. Check installed java version.

    $ java --version
    openjdk 17.0.6-ea 2023-01-17 LTS
    OpenJDK Runtime Environment (Red_Hat-17.0.6.0.9-0.3.ea.el9) (build 17.0.6-ea+9-LTS)
    OpenJDK 64-Bit Server VM (Red_Hat-17.0.6.0.9-0.3.ea.el9) (build 17.0.6-ea+9-LTS, mixed mode, sharing)
  5. Install other JRE version if required.

    $ sudo dnf install --assumeyes java-11-openjdk
    Last metadata expiration check: 2:00:49 ago on Thu 26 Jan 2023 10:27:45 AM +08.
    Dependencies resolved.
    ==========================================================================================================================================================================
     Package                                         Architecture                   Version                                            Repository                        Size
    ==========================================================================================================================================================================
    Installing:
     java-11-openjdk                                 aarch64                        1:11.0.18.0.9-0.3.ea.el9                           appstream                        436 k
    Installing dependencies:
     java-11-openjdk-headless                        aarch64                        1:11.0.18.0.9-0.3.ea.el9                           appstream                         39 M
    
    Transaction Summary
    ==========================================================================================================================================================================
    Install  2 Packages
    
    Total download size: 39 M
    Installed size: 176 M
    ##### snipped
  6. Change default java version if required.

    $ sudo alternatives --config java
    
    There are 2 programs which provide 'java'.
    
      Selection    Command
    -----------------------------------------------
       1           java-17-openjdk.aarch64 (/usr/lib/jvm/java-17-openjdk-17.0.6.0.9-0.3.ea.el9.aarch64/bin/java)
    *+ 2           java-11-openjdk.aarch64 (/usr/lib/jvm/java-11-openjdk-11.0.18.0.9-0.3.ea.el9.aarch64/bin/java)
    
    Enter to keep the current selection[+], or type selection number: 1
  7. Check current default JRE version.

    $ java --version
    openjdk 17.0.6-ea 2023-01-17 LTS
    OpenJDK Runtime Environment (Red_Hat-17.0.6.0.9-0.3.ea.el9) (build 17.0.6-ea+9-LTS)
    OpenJDK 64-Bit Server VM (Red_Hat-17.0.6.0.9-0.3.ea.el9) (build 17.0.6-ea+9-LTS, mixed mode, sharing)