Last Updated: October 04, 2020
· junior-ales

Multiple JDK Installed? Here's how to set one default

So you have in your Debian based system multiple JDK installed and are strugling to set one of them as default? Run the following command:

sudo update-alternatives --config java

It will prompt something like:

There are 2 choices for the alternative java (providing /usr/bin/java).

 Selection    Path                                  Priority     Status

0        /usr/lib/jvm/java-6.31-oracle/bin/java     1062      auto mode
1        /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
2        /usr/lib/jvm/java-6.31-oracle/bin/java     1062      manual mode

Press enter to keep the current choice[*], or type selection number:

Then just type the selection number and java --version to check if is everithing right (will be, believe me)


Related protips:

How To Check If JDK Is 32-bit or 64-bit?