本文共 1036 字,大约阅读时间需要 3 分钟。
删除centos7自带的jdk,先输入下面的命令查找已安装的java包
rpm -qa | grep java列出内容如下
java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64javapackages-tools-3.4.1-11.el7.noarchjava-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64tzdata-java-2016g-2.el7.noarchpython-javapackages-3.4.1-11.el7.noarchjava-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_64删除已安装的java
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64rpm -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_64下载jdk-8u191-linux-x64.tar.gz到/opt/soft/,并解压至/usr/local/
tar zxvf /opt/soft/jdk-8u191-linux-x64.tar.gz -C /usr/local/vi /etc/profile
在最后添加下面内容export JAVA_HOME=/usr/local/jdk1.8.0_191export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
保存后输入source /etc/profile更新环境变量
输入java -version和javac既可验证转载地址:http://mytla.baihongyu.com/