CentOS替换系统自带JDK
1.解压jdk安装包到/opt 下
/opt/jdk1.8.0_181
2.编辑/etc/profile, 增加如下内容
export JAVA_HOME=/opt/jdk1.8.0_181
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$PATH:${JAVA_HOME}/bin
3.执行命令
source /etc/profile
4.执行下面命令更新jdk,最后输入数字选择正确的jdk版本
update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_181/bin/java 300
update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_181/bin/javac 300
update-alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_181/bin/jar 300
update-alternatives --config java