在线下载安装包:
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
添加执行权限:
chmod +x jdk-8u131-linux-x64.rpm
执行rpm进行安装
rpm -ivh jdk-8u131-linux-x64.rpm
查看JDK是否安装成功
java -version
编辑环境变量:
vi /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}
保存退出后,让profile立即生效:
source /etc/profile