Home / How to set default Java version with alternatives tool in AlmaLinux

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-1.9.0.292.b10-1.el8_4.x86_64/jre/bin/java)
2 java-12-openjdk.x86_64 (/usr/lib/jvm/java-12-openjdk-11.0.11.0.9-2.el8_4.x86_64/bin/java)

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/java.new: Permission denied

Leave a Reply