Java Runtime Environment (JRE) is required to run Java applications on Linux systems. It includes the Java Virtual Machine (JVM), core Java libraries, and other necessary components. You can install JRE from OpenJDK or Oracle, with OpenJDK being an open-source implementation of the Java SE platform and widely used on Linux distributions like CentOS, Red Hat, and Fedora.
To install JRE, you'll use the package manager yum or dnf, depending on your system. Multiple versions, including Java 8, Java 11, and Java 17, are available in the official repositories. It's important to choose the appropriate version of JRE for your specific needs, such as legacy applications requiring Java 8 or newer software requiring Java 11 or Java 17.
Once the JRE is installed, it may be necessary to verify the installation and configure the system to use a specific version by default. Switching between different versions is also possible if your applications need different JRE versions.
Steps to install Java Runtime Environment (JRE) on CentOS, Fedora and Red Hat:
- Open the terminal.
- 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
- Install the preferred version of OpenJDK JRE.
$ 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
- Verify the 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)
- Install another version of JRE 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
- Change the 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
- Confirm the 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)
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.