linux下,手动切换jdk

Posted 寻步

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux下,手动切换jdk相关的知识,希望对你有一定的参考价值。

1、首先将自定义的jdk目录安装到alternatives中

[email protected]:~/srcandroid/src4.4.4_r1$ sudo update-alternatives --install /usr/bin/java java /home/seven/Documents/Android/jdk1.6.0_45/bin/java 700
[email protected]:~/srcAndroid/src4.4.4_r1$ sudo update-alternatives --install /usr/bin/javac javac /home/seven/Documents/Android/jdk1.6.0_45/bin/javac 700
[email protected]:~/srcAndroid/src4.4.4_r1$ sudo update-alternatives --install /usr/bin/jar jar /home/seven/Documents/Android/jdk1.6.0_45/bin/jar 700
[email protected]:~/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、选择

[email protected]:~/srcAndroid/src4.4.4_r1$ sudo update-alternatives --config java//可以是javac、javah、jar
[sudo] password for seven: 
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                                Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java       1071      auto mode
* 1            /home/seven/Documents/Android/jdk1.6.0_45/bin/java   700       manual mode
  2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java       1071      manual mode

Press <enter> to keep the current choice[*], or type selection number:

3、验证

[email protected]:~/srcAndroid/src4.4.4_r1$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
[email protected]:~/srcAndroid/src4.4.4_r1$ 

 

以上是关于linux下,手动切换jdk的主要内容,如果未能解决你的问题,请参考以下文章

Linux下jdk的安装卸载切换

linux jdk版本随时切换

linux jdk版本随时切换

Linux 多个JDK的版本 脚本切换

Linux下手动编译JDK8源码~~安排!

linux下jdk安装