1、首先将自定义的jdk目录安装到alternatives中
seven@ThinkPad:~/srcAndroid/src4..4_r1$ sudo update-alternatives --install /usr/bin/java java /home/seven/Documents/Android/jdk1..0_45/bin/java 700
seven@ThinkPad:~/srcAndroid/src4.4.4_r1$ sudo update-alternatives --install /usr/bin/javac javac /home/seven/Documents/Android/jdk1.6.0_45/bin/javac 700
seven@ThinkPad:~/srcAndroid/src4.4.4_r1$ sudo update-alternatives --install /usr/bin/jar jar /home/seven/Documents/Android/jdk1.6.0_45/bin/jar 700
seven@ThinkPad:~/srcAndroid/src4.4.4_r1$ sudo update-alternatives --install /usr/bin/javah javah /home/seven/Documents/Android/jdk1.6.0_45/bin/javah 700
2、选择
seven@ThinkPad:~/srcAndroid/src4..4_r1$ sudo update-alternatives --config java//可以是javac、javah、jar
[sudo] password for seven:
There are choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status
------------------------------------------------------------
/usr/lib/jvm/java--openjdk-amd64/jre/bin/java auto mode
* /home/seven/Documents/Android/jdk1..0_45/bin/java manual mode
/usr/lib/jvm/java--openjdk-amd64/jre/bin/java manual mode Press <enter> to keep the current choice[*], or type selection number:
3、验证
seven@ThinkPad:~/srcAndroid/src4..4_r1$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) -Bit Server VM (build 20.45-b01, mixed mode)
seven@ThinkPad:~/srcAndroid/src4..4_r1$