이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 1. Interactively selecting a system-wide Red Hat build of OpenJDK version on RHEL
If you have multiple versions of Red Hat build of OpenJDK installed on RHEL, you can interactively select the default Red Hat build of OpenJDK version to use system-wide.
If you do not have root privileges, you can select a Red Hat build of OpenJDK version by configuring the JAVA_HOME environment variable.
Prerequisites
- You must have root privileges on the system.
-
Multiple versions of Red Hat build of OpenJDK were installed using the
yumpackage manager.
Procedure
View the Red Hat build of OpenJDK versions installed on the system.
$ yum list installed "java*"A list of installed Java packages appears.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display the Red Hat build of OpenJDK versions that can be used for a specific
javacommand and select the one to use:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The current system-wide Red Hat build of OpenJDK version is marked with an asterisk.
-
The current Red Hat build of OpenJDK version for the specified
javacommand is marked with a plus sign.
Press Enter to keep the current selection or enter the Selection number of the Red Hat build of OpenJDK version you want to select followed by the Enter key.
The default Red Hat build of OpenJDK version for the system is the selected version.
Verify that the chosen binary is selected.
java -version
$ java -version openjdk version "17" 2021-09-14 OpenJDK Runtime Environment 21.9 (build 17+35) OpenJDK 64-Bit Server VM 21.9 (build 17+35, mixed mode, sharing)Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis procedure configures the
javacommand. Thenjavaccommand can be set up in a similar way, but it operates independently.If you have Red Hat build of OpenJDK installed,
alternativesprovides more possible selections. In particular, thejavacmaster alternative switches many binaries provided by the-develsub-package.Even if you have Red Hat build of OpenJDK installed,
java(and other JRE masters) andjavac(and other Red Hat build of OpenJDK masters) still operate separately, so you can have different selections for JRE and JDK. Thealternatives --config javacommand affects thejreand its associated slaves.If you want to change Red Hat build of OpenJDK, use the
javac alternativescommand. The--config javacutility configures theSDKand related slaves. To see all possible masters, usealternatives --listand check all of thejava,javac,jre, andsdkmasters.