[HOW TO] change the Java default in Ubuntu?



Hello,



I am come back here. Today we are having the scenario follows:

On computer, Java JRE 6update 45 already installed. Now we want to install more Java JRE 7update10 for testing. I wondered how to change the Java default?

And, ... here are reply

For Java :
update-alternatives --config java 

For Java compiler :
update-alternatives --config javac 
For Java web start :
update-alternatives --config javaws

Example:


Using update-alternatives you can manage multiple jdk libraries on the same system, choosing which one you want to use as the main one. First you have to install an alternative for the new installed
:

root@TP-M9999:/home/pttien# update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jre1.6.0_45/bin/javaws 1

root@TP-M9999:/home/pttien# update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/jre1.6.0_25/bin/java 1 auto mode
* 1 /usr/lib/jvm/jre1.6.0_25/bin/java 1 manual mode
2 /usr/lib/jvm/jre1.6.0_45/bin/java 1 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jre1.6.0_45/bin/java to provide /usr/bin/java (java) in manual mode
root@TP-M9999:/home/pttien#
root@TP-M9999:/home/pttien# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)


At any time you can see what alternatives you have for java or javac using the --list option: 
root@TP-M9999:/home/pttien# update-alternatives --list java
/usr/lib/jvm/jre1.6.0_25/bin/java
/usr/lib/jvm/jre1.6.0_45/bin/java

 
Okay! now the Java default is 6update45.

-
Tien

0 nhận xét:

Post a Comment