centos7.4安装jdk1.8.0

1、查看已经安装的jdk

rpm -qa|grep jdk

#java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64

#java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64

#java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64

#java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64

2、卸载命令

sudo yum -y remove java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64

3、验证卸载是否成功

java -version

#bash: java: command not found...

4、下载jdk

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 

5、解压到安装目录

sudo mkdir /usr/local/java

sudo tar -zxvf jdk-8u161-linux-x64.tar.gz -C /usr/local/java/

6、添加用户环境变量

系统环境变量省略

export JAVA_HOME=/usr/local/java/jdk1.8.0_191

export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$PATH:$JAVA_HOME/bin

7、验证

source /home/test/.bash_profile

java -version

你可能感兴趣的:(centos7.4安装jdk1.8.0)