1. 安装JDK包
[root@120_234_2_74_centos7 tools]# tar -xf jdk-8u131-linux-x64.tar.gz -C /usr/local/ [root@120_234_2_74_centos7 tools]# ln -s /usr/local/jdk1.8.0_131/ /usr/local/jdk
2. 添加环境变量
sed -i.bak '$a export JAVA_HOME=/usr/local/jdk export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile
一键安装
tar -xf jdk-8u131-linux-x64.tar.gz -C /usr/local/ ln -s /usr/local/jdk1.8.0_131/ /usr/local/jdk sed -i.bak '$a export JAVA_HOME=/usr/local/jdk export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile source /etc/profile