1、准备

先下载JDK1.8
官网:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

2、卸载自带JDK

先检查是否有安装JDK:

rpm -qa | grep jdk

1573051627969

卸载系统自带的JDK:

rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

在执行rpm -qa | grep jdk命令,可以看见自带的JDK已卸载干净

1573051709156

3、解压

新建/usr/local/java目录:

sudo mkdir /usr/local/java

将下载的JDK1.8拷贝到java目录下,在java目录中执行解压命令:

cd /usr/local/java
sudo tar zxvf jdk-8u171-linux-x64.tar.gz

4、

# java环境变量
JAVA_HOME=/usr/local/java/jdk1.8.0_171
JRE_HOME=/usr/local/java/jdk1.8.0_171/jre
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME CLASSPATH

5、


Viva La Vida