1、查找是否已安装JDK
rpm -qa | grep java#显示java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64tzdata-java-2016g-2.el7.noarchjavapackages-tools-3.4.1-11.el7.noarchjava-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64python-javapackages-3.4.1-11.el7.noarch
2、卸载自带的JDK(rpm或yum命令[yum -y remove xxx])
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64rpm -e --nodeps tzdata-java-2016g-2.el7.noarchrpm -e --nodeps javapackages-tools-3.4.1-11.el7.noarchrpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64rpm -e --nodeps python-javapackages-3.4.1-11.el7.noarch
3、安装JDK
tar -xzvf jdk-8u111-linux-x64.tar.gz
vi /etc/profile
追加:
JAVA_HOME=/app/jdk1.8.0_111
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
echo "export JAVA_HOME=/app/jdk1.8.0_111" >> /etc/profile
4、验证
java -version