CentOS7.0安装JDK1.8.0_31

分类:CentOS教程 阅读:89209 次

1.检查一下系统中的jdk版本

  1. $>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安装包

  1. $>rpm-qa|grepjava
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

  1. $>rpm-e--nodepstzdata-java-2014i-1.el7.noarch
  2. $>rpm-e--nodepsjava-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
  3. $>rpm-e--nodepsjava-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
4.安装新的Jdk1.8.0_31

解压缩tar.gz

  1. $>mkdir-p/usr/lib/jvm
  2. $>tar-zxvfjdk1.8.0_31.tar.gz-C/usr/lib/jvm
5.设置环境变量
  1. $>vi/etc/profile
在最后添加:
  1. exportJAVA_HOME=/usr/lib/jvm/jdk1.8.0_31
  2. exportJRE_HOME=${JAVA_HOME}/jre
  3. exportCLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
  4. exportPATH=${JAVA_HOME}/bin:$PATH

6.执行profile
  1. $>source/etc/profile

7.检查新安装的jdk

  1. $>java-version