1.首先查看已经安装的jdk
rpm -qa|grep jdk
2.卸载其他版本的jdk(这里卸载自带的1.8openjdk,删除headless)
yum -y remove java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
3.下载jdk,解压到安装目录
去官网下载jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
解压到安装目录tar -zxvf jdk-8u101-linux-x64.tar.gz -C /usr/local/java/
4.安装完毕后在/etc/profile文件末尾添加
vim /etc/profile
JAVA_HOME=/usr/local/java/jdk1.8.0_144/
export PATH=$PATH:$JAVA_HOME/bin
5.使/etc/profile文件生效
source /etc/profile
6.查看是否安装成功java - version