zoukankan      html  css  js  c++  java
  • 在CentOS 7中安装与配置JDK8

    1. 检查已经安装的jdk

    rpm -qa | grep java

    可能的结果如下:

    java-1.7.0-openjdk-1.7.0.99-2.6.5.0.el7_2.x86_64
    python-javapackages-3.4.1-11.el7.noarch
    java-1.8.0-openjdk-headless-1.8.0.77-0.b03.el7_2.x86_64
    java-1.8.0-openjdk-1.8.0.77-0.b03.el7_2.x86_64
    tzdata-java-2016c-1.el7.noarch
    javapackages-tools-3.4.1-11.el7.noarch
    java-1.7.0-openjdk-headless-1.7.0.99-2.6.5.0.el7_2.x86_64

    2. 移除已经安装的open-jdk及依赖的程序

    yum remove tzdata-java-2016c-1.el7.noarch

    此时所有的open-jdk和其它对open-jdk有依赖的软件都会被移除

    3.到oracle下载jdk8, 如我下载的是jdk-8u65-linux-x64.rpm

    在对应目录下执行安装命令:

    rpm -ivh jdk-8u65-linux-x64.rpm

    程序默认安装到 /usr/java/jdk1.8.0_65

    检查安装情况:

    [root@pole jdk]# java -version
    java version "1.8.0_65"
    Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
    Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
    [root@pole jdk]# javac -version
    javac 1.8.0_65

    检查文件路径:

    [root@pole jdk]# whereis java
    java: /usr/bin/java /usr/lib/java /etc/java /usr/share/java /usr/share/man/man1/java.1
    [root@pole jdk]# ll /usr/bin/java
    lrwxrwxrwx 1 root root 22 Mar 28 11:52 /usr/bin/java -> /etc/alternatives/java
    [root@pole jdk]# ll /etc/alternatives/java
    lrwxrwxrwx 1 root root 34 Mar 28 11:52 /etc/alternatives/java -> /usr/java/jdk1.8.0_65/jre/bin/java

    添加环境变量文件:

    [root@pole jdk]# vi /etc/profile.d/jdk8.sh

    添加以下内容

    JAVA_HOME=/usr/java/jdk1.8.0_65
    JRE_HOME=/usr/java/jdk1.8.0_65/jre
    CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
    
    export JAVA_HOME JRE_HOME CLASSPATH

    使修改生效

    source /etc/profile

    检查是否生效

    [root@pole jdk]# env|grep java
    JRE_HOME=/usr/java/jdk1.8.0_65/jre
    JAVA_HOME=/usr/java/jdk1.8.0_65
    CLASSPATH=.:/usr/java/jdk1.8.0_65/lib/dt.jar:/usr/java/jdk1.8.0_65/lib/tools.jar:/usr/java/jdk1.8.0_65/jre/lib

    到此OK了.

  • 相关阅读:
    BZOJ 3144 [Hnoi2013]切糕
    一场比赛:20170707
    BZOJ 2815 [ZJOI2012]灾难
    BZOJ 1088 [SCOI2005]扫雷Mine
    BZOJ 1052 [HAOI2007]覆盖问题
    BZOJ 3505 [Cqoi2014]数三角形
    BZOJ 2957 楼房重建
    BZOJ 2654 tree
    丁酉年六月十一ACM模拟赛
    BZOJ 3438 小M的作物 & BZOJ 1877 [SDOI2009]晨跑
  • 原文地址:https://www.cnblogs.com/equation/p/5328523.html
Copyright © 2011-2022 走看看