查看系统所安装的JDK版本root@ubuntu:~# java -version
java version “1.7.0_79”
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
2.将JDK上传到/opt目录中root@ubuntu:~# cd /opt
root@ubuntu:/opt# ls
jdk-6u45-linux-x64.bin3.修改JDK的权限root@ubuntu:/opt# chmod +x jdk-6u45-linux-x64.bin4.执行JDK文件root@ubuntu:/opt# ./jdk-6u45-linux-x64.bin5.查看解压出来的目录root@ubuntu:/opt# ls
jdk1.6.0_45 jdk-6u45-linux-x64.bin
6.创建软链接root@ubuntu:/opt# ln -s jdk1.6.0_45/ java
root@ubuntu:/opt# ls
java jdk1.6.0_45
7.修改环境变量配置文件root@ubuntu:/opt# vim /etc/profile#set java environment
export JAVA_HOME=/opt/java
export JRE_HOME=/opt/java
export CLASSPATH==.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
8.让配置文件生效root@ubuntu:/opt# source /etc/profile9.查看java的版本root@ubuntu:~# java -version
java version “1.7.0_79”
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
10.查看新配置的JAVA版本root@ubuntu:~# /opt/java/bin/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)
11.创建链接root@ubuntu:~# update-alternatives –install /usr/bin/java java /opt/java/bin/java 300
root@ubuntu:~# update-alternatives –install /usr/bin/javac javac /opt/java/bin/javac 300
update-alternatives: using /opt/java/bin/javac to provide /usr/bin/javac (javac) in auto mode12.配置系统默认的JAVA环境root@ubuntu:~# update-alternatives –config java
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 /opt/java/bin/java 300 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual modePress enter to keep the current choice[*], or type sele免费云主机域名ction number: 1
root@ubuntu:~# update-alternatives –config javac
There is only one alternative in link group javac (providing /usr/bin/javac): /opt/java/bin/javac
Nothing to configure.
13.查看是否生效root@ubuntu:~# 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)
A status of “expired” means that the backup piece or backup set is not found in the backup destination. With tape management syste…
免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。