How to use the command update-alternatives --config java

后端 未结 8 1637
北恋
北恋 2020-11-28 22:05

I am installing Apache Solr on Linux Debian (Squeeze). I have been instructed to install sun-java jdk 1st. Then am told that I should use the command sudo update-alter

相关标签:
8条回答
  • 2020-11-28 23:07

    Assuming one has installed a JDK in /opt/java/jdk1.8.0_144 then:

    1. Install the alternative for javac

      $ sudo update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.8.0_144/bin/javac 1
      
    2. Check / update the alternatives config:

      $ sudo update-alternatives --config javac
      

    If there is only a single alternative for javac you will get a message saying so, otherwise select the option for the new JDK.

    To check everything is setup correctly then:

    $ which javac
    /usr/bin/javac
    
    $ ls -l /usr/bin/javac
    lrwxrwxrwx 1 root root 23 Sep  4 17:10 /usr/bin/javac -> /etc/alternatives/javac
    
    $ ls -l /etc/alternatives/javac
    lrwxrwxrwx 1 root root 32 Sep  4 17:10 /etc/alternatives/javac -> /opt/java/jdk1.8.0_144/bin/javac
    

    And finally

    $ javac -version
    javac 1.8.0_144
    

    Repeat for java, keytool, jar, etc as needed.

    0 讨论(0)
  • 2020-11-28 23:07

    If you want to switch the jdk on a regular basis (or update to a new one once it is released), it's very conveniant to use sdkman.

    You can additional tools like maven with sdkman, too.

    0 讨论(0)
提交回复
热议问题