centos jdk 1.7升级到1.8后显示还是1.7

系统原来安装的是jdk 1.7,现在要升级到1.8,查看了一下,原来是通过解压的方式安装的,
现在重新按这种方式安装1.8

1 下载jdk1.8
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
找到下载链接
然后在linux中:

wget http://111.1.50.111/files/323000000641B15B/download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz
--2017-11-04 16:58:18--  http://111.1.50.111/files/323000000641B15B/download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz
Connecting to 111.1.50.111:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 189736377 (181M) [application/octet-stream]
Saving to: ‘jdk-8u151-linux-x64.tar.gz100%[=======================================================================================================>] 189,736,377 13.6MB/s   in 15s    

2017-11-04 16:58:32 (12.5 MB/s) - ‘jdk-8u151-linux-x64.tar.gz’ saved [189736377/189736377]
[root@izwz95v28cpic4beuk0rk0z java]# ls
jdk1.7.0_79  jdk-7u79-linux-x64.tar.gz  jdk-8u151-linux-x64.tar.gz

下载成功.

tar -xzvf  jdk-8u151-linux-x64.tar.gz
[root@izwz95v28cpic4beuk0rk0z java]# ls
jdk1.7.0_79  jdk1.8.0_151  jdk-7u79-linux-x64.tar.gz  jdk-8u151-linux-x64.tar.gz
[root@izwz95v28cpic4beuk0rk0z jdk1.8.0_151]# pwd
/usr/java/jdk1.8.0_151
vim  /etc/profile

# java env
# java env
JAVA_HOME=/usr/java/jdk1.8.0_151
PATH=$PATH:${JAVA_HOME}/bin
CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH JAVA_HOME CLASSPATH
root@izwz95v28cpic4beuk0rk0z jdk1.8.0_151]# java -version
java version "1.7.0_79"

查看Jdk版本还是1.7,最后发现PATH应该这样写:

PATH=${JAVA_HOME}/bin:$PATH

要把$JAVA_HOME/bin放在前面,不然使用java命令时,系统会找到以前 的java

你可能感兴趣的:(java)