How to set default Java version with alternatives tool in AlmaLinux

  • When different Java versions are installed on a Linux server, use the alternatives tool to set the default Java version as follows:

alternatives --config java
There are 2 program that provides 'java'.
Selection Command
*+ 1 java-1.9.0-openjdk.x86_64 (/usr/lib/jvm/java-1.9.0-openjdk-
2 java-12-openjdk.x86_64 (/usr/lib/jvm/java-12-openjdk-

Enter to keep the current selection[+], or type selection number: 2

  • Type 1 or 2 to select default Java for OS. Note that this command can be run as root only. If this command is run as a user following error is returned.

failed to create /var/lib/alternatives/ Permission denied

Leave a Reply