1. 下载安装包

    wget https://inapp.oss-cn-qingdao.aliyuncs.com/static/jdk-8u162-linux-x64.tar.gz  -P /tmp/
    tar xfz /tmp/jdk-8u162-linux-x64.tar.gz  -C  /srv
    ln -s /srv/jdk1.8.0_162 /srv/jdk1.8
    
  2. 设置环境变量

    cat << 'EOF' > /etc/profile.d/jdk.sh
    export JAVA_HOME=/srv/jdk1.8
    export JRE_HOME=$JAVA_HOME/jre
    export PATH=$PATH:$JAVA_HOME/bin
    EOF
    
  3. 校验安装版本

    # exec bash
    # java -version
    
    java version "1.8.0_162"
    Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)