Choosing a Java Version on Ubuntu

When you have got multiple versions of Java installed, you can choose which one you want to use by running the update-alternatives command.

Running this command shows a list of installed Java JDKs and JREs allowing one to be selected as the default that is used when java needs to be executed.


$ sudo update-alternatives --config javac

If you prefer to use a gui instead of the command line, you can execute galternatives instead and define the default versions of software with the following dialog.


$ sudo galternatives