1.下载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
2.添加权限
chmod +x jdk-8u131-linux-x64.rpm
3.rmp安装
rpm -ivh jdk-8u131-linux-x64.rpm
4.查看
java -version
能显示jdk版本证明安装成功
5.修改环境变量
打开配置文件:
vim /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}
保存退出:
:wq