#解压安装包
[root@xxx]tar zxvf jdk-8u161-linux-x64.tar.gz
#修改环境变量
[root@xxx]# vi /etc/profile
#set for java jdk
JAVA_HOME=/java/jdk1.8.0_161
JRE_HOME=/java/jdk1.8.0_161/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
#是配置文件起作用
[root@xxx]# source /etc/profile
#查看是否安装成功
[root@xxx]# java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)