How to set default Java version with alternatives tool in RHEL on a per user basis
Issue
-
When different Java versions are installed on a RHEL system, using the
alternatives
tool as a regular user fails to set the default version.# alternatives --config java There is 2 program that provides 'java'. Selection Command ----------------------------------------------- *+ 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el8_4.x86_64/jre/bin/java) 2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-2.el8_4.x86_64/bin/java) Enter to keep the current selection[+], or type selection number: 2 failed to create /var/lib/alternatives/java.new: Permission denied
-
Using the
alternatives
tool allows you to set the system default version asroot
but does not currently provide options to set different defaults for individual users. - How do you set the default Java version for individual users using the
alternatives
tool?
Environment
- Red Hat Enterprise Linux (RHEL)
- 7
- 8
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.