Hi,
First install the two version of java by issuing the commands.
apt-get install openjdk-6-jre
apt-get install openjdk-7-jre
It will install the two version of java but the last installed version can be used by default on the system.
The installation path will be
/usr/lib/jvm/java-7-openjdk-i386
/usr/lib/jvm/java-6-openjdk-i386
By default the java bin path /usr/bin/java is linked to the file /etc/alternatives/java which is linked to /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java(if it is installed first). Other wise the link will be to /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java
To use a different version of java on the same ubuntu machine, we need to export the java home path using the command
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/
If you need to make it permenant you need to add this in the .bashrc file.
Other wise there is another command which will help to change the java version.
which is
update-alternatives --config java
which will list the installed java versions
update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status ------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java 1061 manual mode
* 2 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1051 manual mode
3 /usr/lib/jvm/java-7-oracle/jre/bin/java 1 manual mode
If you want to use java version 1.6 choose the first one and enter it will change the binary path of the java to the new one.
Regards
Syamkumar
First install the two version of java by issuing the commands.
apt-get install openjdk-6-jre
apt-get install openjdk-7-jre
It will install the two version of java but the last installed version can be used by default on the system.
The installation path will be
/usr/lib/jvm/java-7-openjdk-i386
/usr/lib/jvm/java-6-openjdk-i386
By default the java bin path /usr/bin/java is linked to the file /etc/alternatives/java which is linked to /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java(if it is installed first). Other wise the link will be to /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java
To use a different version of java on the same ubuntu machine, we need to export the java home path using the command
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/
If you need to make it permenant you need to add this in the .bashrc file.
Other wise there is another command which will help to change the java version.
which is
update-alternatives --config java
which will list the installed java versions
update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status ------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java 1061 manual mode
* 2 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1051 manual mode
3 /usr/lib/jvm/java-7-oracle/jre/bin/java 1 manual mode
If you want to use java version 1.6 choose the first one and enter it will change the binary path of the java to the new one.
Regards
Syamkumar
Thank you!
ReplyDelete