1、安装前检查是否有jdk安装,删除已安装的jdk
rpm -qa | grep jdk
rpm -qa | grep gcj
yum -y remove java-xxx-xxx
2、wget下载jdk安装包
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
3、添加rpm包权限
chmod +x jdk-8u131-linux-x64.rpm
4、执行rmp安装
rpm -ivh jdk-8u131-linux-x64.rpm
5、jdk版本查看
java -version 默认安装路径/usr/java/jdk1.8.0_131
6、修改配置文件 /etc/profile
增加
export JAVA_HOME=/usr/java/jdk1.8.0_131
export JRE_HOME=({JAVA_HOME}/jre
export CLASSPATH=.:){JAVA_HOME}/lib:({JRE_HOME}/lib:)CLASSPATH
export JAVA_PATH=({JAVA_HOME}/bin:){JRE_HOME}/bin
export PATH=(PATH:){JAVA_PATH}
7、使配置文件生效 source /etc/profile