Completely uninstall and reinstall OpenJDK

2,936

Solution 1

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.

Solution 2

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

Solution 3

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.

Share:
2,936

Related videos on Youtube

Mephi_stofel
Author by

Mephi_stofel

Updated on September 18, 2022

Comments

  • Mephi_stofel
    Mephi_stofel almost 2 years

    The following works fine when I type it exactly in the command line:

    find /<some_path>/{epson,epson_laser,epson_inkjet} -iname "*.ppd" 
      -exec grep "\*ModelName\:" {} \; | sed 's/.*\"\(.*\)\"/\1/'
    

    However, when I try to call the following from a bash script I get find: missing argument to -exec'.

    I have also tried the following (in many variants):

    eval find "$1" -iname "*.ppd" -exec 'bash -c grep "\*ModelName\:" "$1" | sed "s/.*\"\(.*\)\"/\1/" \;
    

    as was mentioned in find-exec-echo-missing-argument-to-exec. How can I get to work first code not only in terminal, but also in bash script?

    P.S.: I've used eval only for expanding string "/<some_path>/{epson,epson_laser,epson_inkjet}" to multiple paths. Does anyone know better solution for doing this?

    • Mr Lou
      Mr Lou about 12 years
      get the answer: sudo dpkg --list; sudo dpkg --list | grep -i jdk thanks @izx
    • Barmar
      Barmar over 11 years
      That error means that the \; argument isn't being seen, but it looks fine to me above. Please paste the exact find line from your script.
    • Mephi_stofel
      Mephi_stofel over 11 years
      Well, doesn't matter which find line in script as no one works ;) But how to get the same result as in the first line I typed, but get it to work in bash script? the first line work when I type it directly to terminal, but in bash it in any combination doesn't work.
    • Barmar
      Barmar over 11 years
      When you use eval you have to double up the escapes. The first one escapes the character for the original shell, the second one escapes it for eval.
    • Barmar
      Barmar over 11 years
      That's why it's better to put the -exec command into a script, so you don't need to use eval.
    • Barmar
      Barmar over 11 years
      Actually, I'm not sure why you need to use eval in the first place.
    • gniourf_gniourf
      gniourf_gniourf over 11 years
      Maybe you should also tell us what you're really trying to achieve. We could find the best approach to your problem.
  • Mr Lou
    Mr Lou about 12 years
    How can i search the packages i installed?What is the difference between packages available and packages installed?
  • Mr Lou
    Mr Lou about 12 years
    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.
  • ish
    ish about 12 years
    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"
  • Mr Lou
    Mr Lou about 12 years
    thanks @izx i successed remove openjdk.How can i close the question.
  • ish
    ish about 12 years
    Please remember to accept the answer if it helped -- this will also close the question. Thanks :)