原jdk7位置:/usr/java/jdk1.7.0_80
新jdk8位置:/usr/java/jdk1.8.0_212
[root@localhost ~] which java
/usr/bin/java
[root@localhost ~] rm -f /usr/bin/java && ln -s /usr/java/jdk1.8.0_212/bin/java /usr/bin/java
[root@localhost ~]
更改环境变量,将原来JAVA_HOME指向1.7的路径更改成1.8的
[root@localhost ~] vi /etc/profile
#export JAVA_HOME=/usr/java/jdk1.7.0_80
export JAVA_HOME=/usr/java/jdk1.8.0_212
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
使环境变量生效
[root@localhost ~] source /etc/profile
再查看当前java版本
[root@localhost ~] java -version
java version "1.8.0_212"
Java(TM) SE Runtime Environment (build 1.8.0_212-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)
[root@localhost ~]
网友评论