操作環(huán)境
服務(wù)器centos7.3
下載安裝
1,下載jdk安裝包
[root@jdu4e00u53f7 /]# cd /tmp/frank/
[root@jdu4e00u53f7 frank]# ls
redis ruby
[root@jdu4e00u53f7 frank]# mkdir java
[root@jdu4e00u53f7 frank]# cd java
root@jdu4e00u53f7 java]# wget http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1506606437_53a8298a7f88a75406d7764f1f99f9e2
2挣柬,安裝jdk
root@jdu4e00u53f7 java]# tar -zxvf jdk-8u144-linux-x64.tar.gz
3,下載成功的 jdk-8u144-linux-x64.tar.gz文件可能出現(xiàn)下面異常
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
通過(guò)下面命令查看文件的屬性急黎,如果看到文件是html格式,需要先打地址放到瀏覽器然后拿彈出下載界面的那個(gè)下載地址
[root@jdu4e00u53f7 java]# file jdk-8u144-linux-x64.tar.gz
jdk-8u144-linux-x64.tar.gz: HTML document text
配置jdk環(huán)境變量
1委乌,修改系統(tǒng)環(huán)境變量文件
vim /etc/profile
2荣回,向文件里面追加以下內(nèi)容
JAVA_HOME=/tmp/frank/java/jdk1.8.0_144
JRE_HOME=/tmp/frank/java/jdk1.8.0_144/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
3, 使修改生效
[root@jdu4e00u53f7 jdk1.8.0_144]# source /etc/profile //使修改立即生效
[root@jdu4e00u53f7 jdk1.8.0_144]# echo $PATH //查看PATH值
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/frank/java/jdk1.8.0_144/bin:/tmp/frank/java/jdk1.8.0_144/jre/bin
4壕吹,查看jdk環(huán)境配置是否成功
[root@jdu4e00u53f7 jdk1.8.0_144]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)