我无意中安装了,openjdk-9-jre-headless
而我实际上想要openjdk-8-jre-headless
使用
sudo apt install openjdk-9-jre-headless
当我意识到这一点时我
sudo apt remove --purge openjdk-9-jre-headless
sudo apt install openjdk-8-jre-headless
现在我遇到了一个奇怪的情况:
~$ java --version
The program 'java' can be found in the following packages:
* default-jre
* gcj-5-jre-headless
* openjdk-8-jre-headless
* gcj-4.8-jre-headless
* gcj-4.9-jre-headless
* openjdk-9-jre-headless
Try: sudo apt install <selected package>
但:
~$ sudo apt install openjdk-8-jre-headless
Reading package lists... Done
Building dependency tree
Reading state information... Done
openjdk-8-jre-headless is already the newest version (8u131-b11-2ubuntu1.16.04.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
我在这里要做什么?
编辑:
我已经尝试过了
~$ sudo apt install openjdk-8-jre-headless --reinstall
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/27.0 MB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 160472 files and directories currently installed.)
Preparing to unpack .../openjdk-8-jre-headless_8u131-b11-2ubuntu1.16.04.3_amd64.deb ...
Unpacking openjdk-8-jre-headless:amd64 (8u131-b11-2ubuntu1.16.04.3) over (8u131-b11-2ubuntu1.16.04.3) ...
Setting up openjdk-8-jre-headless:amd64 (8u131-b11-2ubuntu1.16.04.3) ...
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
答案1
好的,我明白了:
sudo apt remove --purge openjdk-8-jre-headless
sudo apt autoremove
sudo apt install --reinstall openjdk-8-jre-headless
现在我得到了预期的结果
~$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
答案2
楼主通过先删除 java8 然后重新安装解决了这个问题。但是,如果你已经有了 java 依赖项,例如正在运行的 apache 服务器,或者其他需要 java 运行时的东西,那么这种方法就不适用了。在这种情况下,首先删除 java9,然后直接运行以下命令update-alternatives
:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java" 1
如果需要的话修改java8的路径。