• 如何安装 JAVA 7 (JDK 7u75) 在 CentOS/RHEL 7/6/5 Fedora


    先下载JDK

    For 64 Bit:-

    # cd /opt/
    # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz"

    For 32 Bit:-

    # cd /opt/
    # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-i586.tar.gz"

    解压缩并移动到/opt下
    # tar xzf jdk-7u75-linux-x64.tar.gz
    # mv jdk1.7.0_75 /opt

    设置为默认虚拟机
    # cd /opt/jdk1.7.0_75/
    # alternatives --install /usr/bin/java java /opt/jdk1.7.0_75/bin/java 2
    # alternatives --config java

    出现以下选项时选择4
    There are 4 programs which provide 'java'. Selection Command ----------------------------------------------- * 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java + 2 /opt/jdk1.7.0_60/bin/java 3 /opt/jdk1.7.0_72/bin/java 4 /opt/jdk1.7.0_75/bin/java Enter to keep the current selection[+], or type selection number: 4 [Press Enter]

    # alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_75/bin/jar 2
    # alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_75/bin/javac 2
    # alternatives --set jar /opt/jdk1.7.0_75/bin/jar
    # alternatives --set javac /opt/jdk1.7.0_75/bin/javac 

    现在可以试一下java的版本了,输出如下
    # java -version
    
    java version "1.7.0_75"
    Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

    设置一下环境变量
    cat >> /etc/profile.d/java7.sh << EOF
    export JAVA_HOME=/opt/jdk1.7.0_75
    export JRE_HOME=/opt/jdk1.7.0_75/jre
    export PATH=$PATH:/opt/jdk1.7.0_75/bin:/opt/jdk1.7.0_75/jre/bin
    EOF

     重开一下终端 env|grep HOME 就可以看见结果了

  • 相关阅读:
    过滤字符串
    sql业务分割
    如何用core自动创建model,与数据库连接
    记录日志
    easyui获取选中行上一行的数据
    获取天气插件代码
    粘包问题
    网络编程
    异常处理
    isinstance和issubclass、元类、反射
  • 原文地址:https://www.cnblogs.com/linbc/p/4319509.html
Copyright © 2020-2023  润新知