卸载系统自带的OpenJDK
java -version
rpm -qa | grep java
#卸载
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
java -version
下载8u151_jdk
wget http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz?AuthParam=1514427661_e4f287cc9b671bc0608edc5b397887d7
tar -zxvf jdk-8u151-linux-x64.tar.gz\?AuthParam\=1514427661_e4f287cc9b671bc0608edc5b397887d7
mv jdk1.8.0_151/ /usr/local/
配置JDK
vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_151
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
source /etc/profile
java -version
来源张永光的博客