1、下载jdk
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"
(比较慢,不如直接在电脑下载后用FTP传进去)
2、解压
tar -zxvf jdk-8u141-linux-x64.tar.gz
3、修改配置文件
vi /etc/profile
添加
JAVA_HOME=/java/jdk1.8.0_141 JRE_HOME=$JAVA_HOME/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH
(JAVA_HOME很具自己实际情况填写)
执行保存
source /etc/profile
验证
java -version