When and Why run alternatives --install java jar javac javaws on installing jdk in linux

前端 未结 6 1742
耶瑟儿~
耶瑟儿~ 2021-02-14 08:56

To install java in linux (I used CentOS, RHEL is same too), I used this command

rpm -Uvh /path/to/binary/jdk-7u55-linux-x64.rpm

and verified java

6条回答
  •  甜味超标
    2021-02-14 09:14

    To get a different version of java JRE/JDK as default in your OS:

    sudo alternatives --install /usr/bin/java java [path_to_java_bin] 1 
    

    Example in my case was:

    sudo alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_80/bin/java 1 
    

    Then run a config to select the alternative java version:

     sudo /usr/sbin/alternatives --config java
    

    Choose 1,2 or the option you desire

    Then check the changes by doing:

    java -version
    

提交回复
热议问题