- 进入指定存放JDK的文件
cd /usr/local
mkdir jdk8
- 下载JDK安装包
wget —no-cookies —no-check-certificate —header “Cookie:gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie” “https://download.oracle.com/otn/java/jdk/8u321-b07/df5ad55fdd604472a86a45a217032c7d/jdk-8u321-linux-x64.tar.gz“
- 解压JDK安装包到指定文件夹
mkdir /usr/local/java
cd usr/local/java
tar -zxvf /usr/local/jdk8/jdk-8u141-linux-x64.tar.gz
- 进入环境配置文件
vi /etc/profile
- 在配置文件最下面配置
JAVA_HOME=/usr/local/java/jdk1.8.0_141
JRE_HOME=$JAVA_HOME/jre
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export PATH JAVA_HOME CLASSPATH JRE_HOME
- 使配置文件生效
source /etc/profile
- 查看JDK是否配置成功
java -version