centos7安装JDK

1、卸载自带的 OpenJDK

rpm -qa | grep java
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_64

2、下载jdk-8u291-linux-x64.tar.gz
方法1:

vi /etc/hosts
140.82.113.3  github.com
wget https://github.com/frekele/oracle-java/releases/download/8u181-b13/jdk-8u181-linux-x64.tar.gz

3、解压

tar -zxvf jdk-8u181-linux-x64.tar.gz
mv jdk1.8.0_181/ /usr/local/

4、配置环境变量

vi /etc/profile

最后加入

export JAVA_HOME=/usr/local/jdk1.8.0_181
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin:$CLASSPATH

5、查看版本号

java -version
点赞