Problem changing Java version using alternatives

后端 未结 6 988
遥遥无期
遥遥无期 2021-02-01 07:03

I\'m not quite sure how I got into this mess, but for some reason I\'m not able to change the current version of Java using alternatives. I can run alternatives --config java a

6条回答
  •  长情又很酷
    2021-02-01 07:42

    When using the alternatives method, if you want to use an alternative, it must first be installed. I believe RPMs would include this as a part of the install, but in the case where manual installs are performed, you can still manually install. For example, with java,

    alternatives --install "/usr/bin/java" "java" "/usr/java/example/bin/java" \
     --slave /usr/bin/javac javac /usr/java/example/bin/javac \
     ...
    

    What this does is to install an alternative for the java symlink. For each slave, it also builds/updates the symlink to some other value specified in another alternative, when you switch it. So if you were to switch to a different version of java using alternatives, and the alternative specifies a slave for javac, javac will repoint to the new version as well.

    My full list is as follows:

    alternatives --install /usr/bin/java java /usr/java//bin/java 1500 \
      --slave /usr/bin/ControlPanel ControlPanel /usr/java//jre/bin/ControlPanel \
       --slave /usr/bin/jar jar /usr/java//bin/jar \
       --slave /usr/bin/javac javac /usr/java//bin/javac \
       --slave /usr/bin/javaws javaws /usr/java//bin/javaws \
       --slave /usr/bin/jcontrol jcontrol /usr/java//bin/jcontrol \
       --slave /usr/bin/keytool keytool /usr/java//bin/keytool \
       --slave /usr/bin/orbd orbd /usr/java//bin/orbd \
       --slave /usr/bin/pack200 pack200 /usr/java//bin/pack200 \
       --slave /usr/bin/policytool policytool /usr/java//bin/policytool \
       --slave /usr/bin/rmid rmid /usr/java//bin/rmid \
       --slave /usr/bin/rmiregistry rmiregistry /usr/java//bin/rmiregistry \
       --slave /usr/bin/servertool servertool /usr/java//bin/servertool \
       --slave /usr/bin/tnameserv tnameserv /usr/java//bin/tnameserv \
       --slave /usr/bin/unpack200 unpack200 /usr/java//bin/unpack200 \
       --slave /usr/share/man/man1/java.1 java.1 /usr/java//man/man1/java.1  \ 
       --slave /usr/share/man/man1/javac.1 javac.1 /usr/java//man/man1/javac.1  \ 
       --slave /usr/share/man/man1/javaws.1 javaws.1 /usr/java//man/man1/javaws.1  \ 
       --slave /usr/share/man/man1/keytool.1 keytool.1 /usr/java//man/man1/keytool.1  \ 
       --slave /usr/share/man/man1/orbd.1 orbd.1 /usr/java//man/man1/orbd.1  \ 
       --slave /usr/share/man/man1/pack200.1 pack200.1 /usr/java//man/man1/pack200.1  \ 
       --slave /usr/share/man/man1/policytool.1 policytool.1 /usr/java//man/man1/policytool.1  \ 
       --slave /usr/share/man/man1/rmid.1 rmid.1 /usr/java//man/man1/rmid.1  \ 
       --slave /usr/share/man/man1/rmiregistry.1 rmiregistry.1 /usr/java//man/man1/rmiregistry.1  \ 
       --slave /usr/share/man/man1/servertool.1 servertool.1 /usr/java//man/man1/servertool.1  \ 
       --slave /usr/share/man/man1/tnameserv.1 tnameserv.1 /usr/java//man/man1/tnameserv.1  \ 
       --slave /usr/share/man/man1/unpack200.1 unpack200.1 /usr/java//man/man1/unpack200.1
    

    Hope this helps.

提交回复
热议问题