文章目录

1.下载jdk安装包

链接:https://pan.baidu.com/s/1GztuazCj-587v3em7kc-GA  密码:5am3
[root@VM_0_16_centos opt]# pwd
/opt
[root@VM_0_16_centos opt]# ll
total 186460
drwxr-xr-x 8 10 143 4096 Mar 29 2018 jdk1.8.0_172
-rw-r--r-- 1 root root 190921804 Dec 5 17:22 jdk-8u172-linux-x64.tar.gz
drwxr-xr-x. 2 root root 4096 Oct 31 03:17 rh
[root@VM_0_16_centos opt]#

2.解压安装包

[root@VM_0_16_centos jdk1.8.0_172]# pwd
/opt/jdk1.8.0_172
[root@VM_0_16_centos jdk1.8.0_172]# ll
total 25988
drwxr-xr-x 2 10 143 4096 Mar 29 2018 bin
-r--r--r-- 1 10 143 3244 Mar 29 2018 COPYRIGHT
drwxr-xr-x 4 10 143 4096 Mar 29 2018 db
drwxr-xr-x 3 10 143 4096 Mar 29 2018 include
-rw-r--r-- 1 10 143 5207083 Mar 29 2018 javafx-src.zip
drwxr-xr-x 5 10 143 4096 Mar 29 2018 jre
drwxr-xr-x 5 10 143 4096 Mar 29 2018 lib
-r--r--r-- 1 10 143 40 Mar 29 2018 LICENSE
drwxr-xr-x 4 10 143 4096 Mar 29 2018 man
-r--r--r-- 1 10 143 159 Mar 29 2018 README.html
-rw-r--r-- 1 10 143 424 Mar 29 2018 release
-rw-r--r-- 1 10 143 21100340 Mar 29 2018 src.zip
-rw-r--r-- 1 10 143 106782 Mar 29 2018 THIRDPARTYLICENSEREADME-JAVAFX.txt
-r--r--r-- 1 10 143 145180 Mar 29 2018 THIRDPARTYLICENSEREADME.txt
[root@VM_0_16_centos jdk1.8.0_172]#

3.编辑配置文件,配置环境变量

vim /etc/profile

JAVA_HOME=/opt/jdk1.8.0_172
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH

4.重启机器或执行命令 :source /etc/profile

[root@VM_0_16_centos jdk1.8.0_172]# source /etc/profile

5.校验

[root@VM_0_16_centos jdk1.8.0_172]# java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
[root@VM_0_16_centos jdk1.8.0_172]#