首先下載jdk1.8 去官網下載jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
解壓到指定的目錄 解壓命令 html
#解壓壓縮包 [yuyongxr@instance-2 ~] tar -zxvf jdk-8u221-linux-x64.tar.gz #將文件移動到指定目錄 [yuyongxr@instance-2 ~] sudo mv jdk1.8.0_221/ /usr/local/
而後修改配置文件,設置環境變量,編輯/etc/下的profile文件java
#在最後追加如下配置 [yuyongxr@instance-2 ~]vi /etc/profile export JAVA_HOME=/usr/local/jdk1.8.0_221 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
使/etc/profile生效linux
[yuyongxr@instance-2 ~]$ source /etc/profile
測試oracle
[yuyongxr@instance-2 ~]$ java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)