9

I searched askubuntu and tried the suggestions but failed .I try this question:How to completely uninstall Java?

1.I run sudo apt-cache search openjdk get the following:

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.run sudo apt-get remove openjdk get the following: 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
    get the answer: sudo dpkg --list; sudo dpkg --list | grep -i jdk thanks @izx – janwen May 20 '12 at 8:41
12

You cannot remove OpenJDK 7 because it is not installed. If you are trying to remove OpenJDK 6, try sudo apt-get remove openjdk-6-jdk, or sudo apt-get remove default-jdk.

apt-cache search only shows you available packages, not the packages you have installed. For that, try sudo dpkg --list; sudo dpkg --list | grep -i jdk will show you any JDK-related packages installed on your system.

  • How can i search the packages i installed?What is the difference between packages available and packages installed? – janwen May 20 '12 at 8:27
  • I try both commend you post,get the same results: 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 May 20 '12 at 8:29
  • Please update question with output of sudo dpkg --list | grep -i jdk. Available means "CAN BE installed after downloading" while installed means "IS installed on your system" – ish May 20 '12 at 8:30
  • thanks @izx i successed remove openjdk.How can i close the question. – janwen May 20 '12 at 8:42
  • Please remember to accept the answer if it helped -- this will also close the question. Thanks :) – ish May 20 '12 at 8:43
3

Run this command, which lets you choose which Java installation to make the default:

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
1

Recently, I tried to reinstall Java completely. This may help you to remove it:

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

Then, if you want, install Java:

sudo apt-get install openjdk-8-jdk

Following these steps helped me to solve my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.