Ⅰ.通过 SecureCRT 连接到 Linux(CentOS7) 服务器;
Ⅱ.进入到目录 /usr/local/ 中:
cd /usr/local/
Ⅲ.创建目录 tools:
mkdir -p tools
Ⅳ.进入到目录 /usr/local/tools 中:
cd tools/
Ⅴ.网络下载
①wget --no-check-certificate --no-cookies --header "Cookie: Oraclelicense=accept-securebackup-cookie"
http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm
②wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"
http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz
Ⅵ.解压缩 jdk-8u91-linux-x64.tar.gz 文件:
tar -zxvf
jdk-8u161-linux-x64.tar.gz
Ⅶ.返回到上一级并创建 /usr/local/jdk 目录:
mkdir -p jdk
Ⅷ.转移目录
mv /usr/local/tools/jdk1.8.0_161/ /usr/local/jdk/
Ⅸ.打开 /etc/ 目录下的 profile 文件:
vim /etc/profile
将如下代码追加到 profile 文件末尾:
# idea - jdk8 settings start 2018-04-17
JAVA_HOME=/usr/local/jdk/jdk1.8.0_161
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib/dt.jar
export JAVA_HOME JRE_HOME PATH CLASSPATH
# idea - jdk8 settings end 2018-04-17
Ⅹ.重新启用新的配置:
source /etc/profile
输入 java -version 查看 JDK 的版本:java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
【完】