完全卸载并重新安装OpenJDK


9

我搜索了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
得到答案: sudo dpkg --list; sudo dpkg --list | grep -i jdk谢谢@izx
janwen 2012年

Answers:


12

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

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


如何搜索已安装的软件包?可用软件包和已安装软件包有什么区别?
1

我尝试都赞扬您的帖子,获得相同的结果: Reading package lists... Done Building dependency tree Reading state information... Done Package default-jdk is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 182 not upgraded.
janwen 2012年

请使用输出更新问题sudo dpkg --list | grep -i jdk。可用表示“下载后可以安装”,而表示“已在系统上安装IS”
ish

谢谢@izx我成功删除了openjdk。如何解决这个问题。
1

请记住,如果有帮助,请接受答案-这也将结束问题。谢谢:)
ish

3

运行以下命令,使您可以选择要进行默认设置的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

2

最近,我试图完全重新安装Java。这可以帮助您将其删除:

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

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

sudo apt-get install openjdk-8-jdk

遵循这些步骤可以帮助我解决问题。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.