目录
1.下载并解压JDK
(1)获取下载地址:
(2)linux命令
格式:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" +下载地址
例:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
(3)解压压缩包
tar -zxvf jdk-8u191-linux-x64.tar.gz
2.配置环境变量
(1)打开配置文件
vi /etc/profile
(2)编辑配置文件
#java
export JAVA_HOME=/usr/local/plugs/java_1.8/jdk1.8.0_191 #自己linux的解压目录
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
(3)生效配置文件
source /etc/profile
3.验证
java -version
#打印类似下面代码表示成功
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)