Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Java 1.6 default over 1.7 in Ubuntu Linux

Here is the output to some inspection that I did:

$ java -version

java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

and

$ update-java-alternatives -l

java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64

and

$ ls /usr/lib/jvm/

default-java  java-1.5.0-gcj-4.6  java-1.6.0-openjdk  java-1.6.0-openjdk-amd64  java-6-openjdk  java-6-openjdk-amd64  java-6-openjdk-common  java-7-openjdk-amd64

With that in mind, how do I go about changing the default to 1.6 so that when I execute java -version, it tells me 1.6?

Thanks!

like image 294
Mr Mikkél Avatar asked Aug 27 '13 19:08

Mr Mikkél


2 Answers

I am on Fedora but I hope that alternatives works the same way on Ubuntu. You need to run update-alternatives --config java (on Fedora just alternatives --config java) to see what options you have. Then type the number of the JDK you want to use and press enter. And that's it:-)

like image 159
Petr Mensik Avatar answered Nov 01 '22 17:11

Petr Mensik


us below command to set the java. sudo update-alternatives --config java

It will display the option to select you appropriate java version

like image 32
Nirbhay Rana Avatar answered Nov 01 '22 16:11

Nirbhay Rana