Here I am going to show how to set default Java version on ubuntu when we have multiple java versions installed.
How to set default Java version on Ubuntu:
It is very simple to set default java version on windows operating system through a beautiful GUI (environment variables), but when coming to the Linux flavors everything has to be addressed on a terminal window through commands.
however, this article helps you to make a specific java version as a default, when you have multiple Java versions installed on your machine.
Set default Java version on Ubuntu:
Currently, I have two different Java versions (Java 8 and Java 11) installed on my machine and Java 8 is acting as default.
Now I am going to change the default Java 8 to 11 using update-alternatives –config java command.
It will ask you to enter your choice to make the default Java version. Choose selection number and press enter. Now your default java version has been updated to Java 11.
It is also equally important to change the javac default version when you change the java default. you can do this by giving the below command.
Verification:
Check the java -version, and javac -version
References:
Happy Learning 🙂