1.检查一下系统中的jdk版本
[java] view plaincopy
$>java -version
java version "1.7.0_"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
2.检测JDK安装包
[java] view plaincopy
$>rpm -qa | grep java
avapackages-tools-3.4.1-6.el7_0.noarch
tzdata-java-2014i-1.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
python-javapackages-3.4.1-6.el7_0.noarch
3.卸载OpenJDK
[java] view plaincopy
$>rpm -e --nodeps tzdata-java-2014i-1.el7.noarch
$>rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
$>rpm -e --nodeps java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
4.安装新的Jdk1.8.0_31
解压缩tar.gz
[java] view plaincopy
$>mkdir -p /usr/lib/jvm
$>tar -zxvf jdk1.8.0_31.tar.gz -C /usr/lib/jvm
5.设置环境变量
[java] view plaincopy
$> vi /etc/profile
在最后添加:
[java] view plaincopy
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_31
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
6.执行profile
[java] view plaincopy
$>source /etc/profile
7.检查新安装的jdk
[java] view plaincopy
$>java -version