Centos7.2 uses rpm to install jdk8
Reprint: http://www.cnblogs.com/zenghua/p/7154311.html
①Download jdk
Go to the jdk download page to find the jdk you want to download and download it with wget
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otnpub/java/jdk/8u131b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
②Install jdk
rpm -ivh jdk-8u131-linux-x64.rpm
③ Configure environment variables (tell the computer where the jdk is)
vim /etc/profile //打开环境变量文件
Enter the insert mode (press the letter i) and add the following paragraph at the end, then press esc and then save and exit (press: wq Enter)
JAVA_HOME=/usr/java/jdk1.8.0_131
CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH CLASSPATH JAVA_HOME
source /etc/profile //重新载入
④ Check whether the installation is completed
java -version
rmp uninstall jdk
rpm -qa|grep jdk //查看版本
rpm -e jdk版本 //卸载