Linux安装多个jdk版本进行切换
程序员文章站
2022-05-06 19:05:55
本文为大家分享了linux jdk安装多个版本切换的具体方法,供大家参考,具体内容如下
1. 上传jdk7 和 jdk8 包
2. 解压
[root@loca...
本文为大家分享了linux jdk安装多个版本切换的具体方法,供大家参考,具体内容如下
1. 上传jdk7 和 jdk8 包
2. 解压
[root@localhost webapps]# tar -zxvf /package/jdk-7u80-linux-x64.tar.gz
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/bin
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)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。