Switch Java version in Ubuntu

Use update-alternative command to change the default Java version:
$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac ...
1 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac ...
2 /usr/lib/jvm/java-8-openjdk-amd64/bin/javac ...
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/javac to provide /usr/bin/javac (javac) in manual mode

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java ...
1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java ...
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java ...
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

Featured Post

When you copy an AWS EC2 snapshot, you can choose to encrypt the copy

Encrypted Snapshots When you copy a snapshot, you can choose to encrypt the copy (if the original snapshot was not encrypted) or you can s...