1:下载JDK 因为有Cookie认证 所以在JDK下载链接前需要加上
wget -c -P /root/Downloads --no-check-certificate --no-cookie --header "Cookie: s_nr=1420682671945; s_cc=true; oraclelicense=accept-securebackup-cookie; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk7-downloads-1880260.html;s_sq=%5B%5BB%5D%5D"
一个完整的例子:
wget -c -P /root/Downloads --no-check-certificate --no-cookie --header "Cookie: s_nr=1420682671945; s_cc=true; oraclelicense=accept-securebackup-cookie; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk7-downloads-1880260.html;s_sq=%5B%5BB%5D%5D" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1501553131_d3e0e6e1aee688dacca109570ef67f05
2:解压JDK
tar -xzvf jdk-8u144-linux-x64.tar.gz
3:配置环境变量
vim /etc/profile
最末加上:export JAVA_HOME=/usr/local/java/jdk/jdk1.8.0_144
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
4:修改的环境变量生效
source /etc/profile
5:验证
java -version