JRehkemper.de

Set default Java Version

If you have multiple Java-Versions installed you most likely want to set a default one.

You can use the alternatives command for that.

[tux@server]$ alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
 + 1           java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64/jre/bin/java)
*  2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java)

Just enter the number of your desired default java-version and the OS will set the links accordingly.

You can now link the java-home to one of the links under /etc/alternatives. The Links in this directory will be automatically updated if you install updates.

profile picture of the author

Jannik Rehkemper

I'm an professional Linux Administrator and Hobby Programmer. My training as an IT-Professional started in 2019 and ended in 2022. Since 2023 I'm working as an Linux Administrator.