1.移除多余的jdk
rpm -qa | grep ‘java|gcj‘ | xargs -t -I {} rpm -e --nodeps {}
rpm -e --nodeps *
rpm-qa|grep jdk
rpm -e --nodeps *
rpm -qa |grep gcj
rpm -qa |grep *
2.从Oracle网站上下载JDK-*.tar.gz
3.解压tar.gz文件,之后拷贝到 /usr/lib/jvm/下
4.配置update-alternatives
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_80/bin/java 300
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_80/bin/javac 300
5.配置环境变量
vi ~/.bash_profile
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_80 export JRE_HOME=/usr/lib/jvm/jdk1.7.0_80/jre export CLASSPATH=.:$JAVA_HOME/bin/dt.jar:$JAVA_HOME/lib/tools.jar:$CLASSPATH export PATH=$JAVA_HOME/bin/:$PATH:$HOME/bin