完全卸载并重新安装 OpenJDK

完全卸载并重新安装 OpenJDK

我搜索了 askubuntu 并尝试了建议但失败了。我尝试了这个问题:如何彻底卸载Java?

1.我运行sudo apt-cache search openjdk得到以下信息:

openjdk-6-dbg - Java runtime based on OpenJDK (debugging symbols) openjdk-6-demo - Java runtime based on OpenJDK (demos and examples) openjdk-6-doc - OpenJDK Development Kit (JDK) documentation openjdk-6-jdk - OpenJDK Development Kit (JDK) openjdk-6-jre - OpenJDK Java runtime, using Hotspot JIT openjdk-6-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless) openjdk-6-jre-lib - OpenJDK Java runtime (architecture independent libraries) openjdk-6-source - OpenJDK Development Kit (JDK) source files icedtea-7-jre-jamvm - Alternative JVM for OpenJDK, using JamVM openjdk-6-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark openjdk-7-dbg - Java runtime based on OpenJDK (debugging symbols) openjdk-7-demo - Java runtime based on OpenJDK (demos and examples) openjdk-7-doc - OpenJDK Development Kit (JDK) documentation openjdk-7-jdk - OpenJDK Development Kit (JDK) openjdk-7-jre - OpenJDK Java runtime, using Hotspot JIT openjdk-7-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless) openjdk-7-jre-lib - OpenJDK Java runtime (architecture independent libraries) openjdk-7-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark openjdk-7-source - OpenJDK Development Kit (JDK) source files

2.运行sudo apt-get remove openjdk 获得以下内容: Reading package lists... Done Building dependency tree
Reading state information... Done Package openjdk-7-jdk is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 182 not upgraded.

答案1

您无法删除 OpenJDK 7,因为没有安装。如果您尝试删除 OpenJDK 6,请尝试sudo apt-get remove openjdk-6-jdksudo apt-get remove default-jdk

apt-cache search仅显示可用的软件包,而不是您已安装的软件包。为此,请尝试sudo dpkg --list;sudo dpkg --list | grep -i jdk将显示系统上安装的任何与 JDK 相关的软件包。

答案2

运行此命令,它可以让您选择将哪个 Java 安装设为默认安装:

sudo update-alternatives --config java

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                           Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java         1         manual mode

答案3

最近,我尝试完全重新安装 Java。这可能会帮助您删除它:

sudo apt-get remove openjdk*
sudo apt-get clean

然后,如果需要的话,安装 Java:

sudo apt-get install openjdk-8-jdk

遵循这些步骤帮助我解决了我的问题。

相关内容