How to install Java Runtime Environment (JRE) on openSUSE and SLES
You need a Java Runtime Environment (JRE) to run Java applications on your system. A JRE includes the Java Virtual Machine (JVM) and other libraries necessary to run Java programs.
You can install a JRE that OpenJDK or Oracle either provides. Oracle's JRE is the official version from Oracle, while OpenJDK's JRE is an open-source implementation of the Java SE platform. Both are pretty similar, though Oracle's JRE may have some additional features that are not available in OpenJDK'a JRE. This guide covers installing OpenJDK's JRE on both OpenSUSE and SUSE Linux Enterprise Server (SLES).
Depending on the options chosen when installing OpenSUSE or SLES, a version of OpenJDK's JRE might already be installed by default. You can still install OpenJDK's JRE on OpenSUSE and SLES if it's not already installed using zypper at the terminal. You can also install multiple versions of the JRE and choose the one you need as required.
Steps to install Java Runtime Environment (JRE) on openSUSE and SLES:
-
Launch terminal.
-
Fetch latest package list from the repositories.
> sudo zypper refresh [sudo] password for root: Retrieving repository 'Update repository of openSUSE Backports' metadata .......[done] Building repository 'Update repository of openSUSE Backports' cache ............[done] Retrieving repository 'Non-OSS Repository' metadata ............................[done] Building repository 'Non-OSS Repository' cache .................................[done] Retrieving repository 'Main Repository' metadata ...............................[done] Building repository 'Main Repository' cache ....................................[done] Retrieving repository 'Update repository with updates from SUSE Linux Enterprise[done] Building repository 'Update repository with updates from SUSE Linux Enterprise 1[done] Retrieving repository 'Main Update Repository' metadata ........................[done] Building repository 'Main Update Repository' cache .............................[done] Retrieving repository 'Update Repository (Non-Oss)' metadata ...................[done] Building repository 'Update Repository (Non-Oss)' cache ........................[done] All repositories have been refreshed.
-
Check for available OpenJDK's JRE versions.
> sudo zypper search openjdk | grep Runtime | java-1_8_0-openjdk | OpenJDK 8 Runtime Environment | package | java-1_8_0-openjdk | OpenJDK 8 Runtime Environment | srcpackage | java-1_8_0-openjdk-headless | OpenJDK 8 Runtime Environment | package | java-9-openjdk | OpenJDK 9 Runtime Environment | package | java-9-openjdk-headless | OpenJDK 9 Runtime Environment | package | java-10-openjdk | OpenJDK 10 Runtime Environment | package | java-10-openjdk-headless | OpenJDK 10 Runtime Environment | package i | java-11-openjdk | OpenJDK 11 Runtime Environment | package | java-11-openjdk | OpenJDK 11 Runtime Environment | srcpackage i | java-11-openjdk-headless | OpenJDK 11 Runtime Environment | package | java-17-openjdk | OpenJDK 17 Runtime Environment | package | java-17-openjdk | OpenJDK 17 Runtime Environment | srcpackage | java-17-openjdk-headless | OpenJDK 17 Runtime Environment | package
The one marked with i is already installed.
-
Install your preferred JRE version.
> sudo zypper --non-interactive install java-17-openjdk Loading repository data... Reading installed packages... Resolving package dependencies... The following 2 NEW packages are going to be installed: java-17-openjdk java-17-openjdk-headless 2 new packages to install. Overall download size: 37.1 MiB. Already cached: 0 B. After the operation, additional 178.1 MiB will be used. ##### snipped
-
Check installed java version.
> java --version openjdk 17.0.5 2022-10-18 OpenJDK Runtime Environment (build 17.0.5+0-suse-150400.3.6.1-aarch64) OpenJDK 64-Bit Server VM (build 17.0.5+0-suse-150400.3.6.1-aarch64, mixed mode)
-
Install other JRE versions if required.
> sudo zypper --non-interactive install java-1_8_0-openjdk Loading repository data... Reading installed packages... Resolving package dependencies... The following 3 NEW packages are going to be installed: java-1_8_0-openjdk java-1_8_0-openjdk-headless lksctp-tools 3 new packages to install. Overall download size: 51.6 MiB. Already cached: 0 B. After the operation, additional 91.1 MiB will be used.
-
Change default java version if required.
> sudo update-alternatives --config java There are 3 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib64/jvm/jre-17-openjdk/bin/java 2705 auto mode 1 /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java 1805 manual mode 2 /usr/lib64/jvm/jre-11-openjdk/bin/java 2105 manual mode 3 /usr/lib64/jvm/jre-17-openjdk/bin/java 2705 manual mode Press <enter> to keep the current choice[*], or type selection number: 2 update-alternatives: using /usr/lib64/jvm/jre-11-openjdk/bin/java to provide /usr/bin/java (java) in manual mode
-
Check current default java version to confirm change.
> java --version openjdk 11.0.17 2022-10-18 OpenJDK Runtime Environment (build 11.0.17+0-suse-150000.3.86.2-aarch64) OpenJDK 64-Bit Server VM (build 11.0.17+0-suse-150000.3.86.2-aarch64, mixed mode)