March 7, 2012

Managing Multiple Java Installation on Ubuntu 11.10

In earlier blog I have discussed how to install Oracle Java 7 JDK (http://magnus-k-karlsson.blogspot.com/2012/01/how-to-install-oracle-jdk-on-ubuntu-11.html), but several application is not compatible with Java 7. And this was the case for me when running JBoss. So in this blog I will show you how to manage several Java installation on the same Ubuntu 11.10 computer.

Instead of changing symbolic link for /usr/bin/java there is a tool for you that does that consistently.

$ sudo 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-7-oracle/bin/java        1063      auto mode
1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode
3            /usr/lib/jvm/java-7-oracle/bin/java        1063      manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/java to provide /usr/bin/java (java) in manual mode.


$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

No comments: