Linux安装多个jdk版本进⾏切换本⽂为⼤家分享了Linux jdk安装多个版本切换的具体⽅法,供⼤家参考,具体内容如下
1. 上传jdk7 和 jdk8 包
2. 解压
[root@localhost webapps]# tar -zxvf /package/
3. 配置jdk变量
 vi /etc/profile
export JAVA_HOME=/package/jdk1.7.0_80
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/binlinux安装jdk18并配置环境变量
4. java -version
5. 给jdk1.7设置序列号
[xxx@localhost home]$ alternatives --install /usr/bin/java java /package/jdk1.7.0_80 3
6. 安装jdk1.8
[xxx@localhost home]$ alternatives --install /usr/bin/java java /package/jdk1.8.0_124 2
7.选择jdk对应的数字--切换jdk版本
[root@localhost ~]# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
[root@localhost ~]# alternatives --config java
There are 3 programs which provide 'java'.
Selection  Command
-
----------------------------------------------
* 1      /package/jdk1.8.0_121/java
2      /package/jdk1.8.0_121/bin/java
+ 3      /package/jdk1.7.0_80/bin/java
Enter to keep the current selection[+], or type selection number: 2
[root@localhost ~]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。