To run Java applications on OpenSUSE or SUSE Linux Enterprise Server (SLES), the Java Runtime Environment (JRE) is required. A JRE contains the Java Virtual Machine (JVM) and essential libraries needed to execute Java programs. Without the correct JRE, Java applications will not function on your system.
Two common JRE options are available: OpenJDK and Oracle. OpenJDK is an open-source implementation of the Java SE platform, while Oracle's JRE is the official version provided by Oracle. Both are widely used, though Oracle's version may include proprietary components not available in OpenJDK. This guide focuses on installing the OpenJDK JRE, commonly used in open-source environments.
Your OpenSUSE or SLES system might already have a version of the OpenJDK JRE installed depending on how the system was set up. If not, or if you require a specific version, you can install or update it using the zypper package manager. You can also manage multiple JRE versions on the system and choose the one required to run your applications.
> 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.
> 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.
> 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
> 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)
> 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.
> 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
> 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)