10

I installed Oracle JDK on Ubuntu 16.04 LTS using the following commands:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

But I tried various suggestions from the forums and that didn't solve the issue. I purged the ppa and did an update also but it wouldn't remove.

JackSlayer94
  • 203
  • 1
  • 2
  • 4

1 Answers1

26

To remove Oracle JDK completely, run the commands given below(one-by-one) from terminal :-

  • Check which JDK packages are installed

    sudo dpkg --list | grep -i jdk

  • Remove Oracle Java 8 completely

    sudo apt-get purge oracle-java8-installer
    sudo apt-get autoremove
    
  • Check that all JDK packages have been removed

    sudo dpkg --list | grep -i jdk

Then if you want to, you can also purge the PPA.

Gautam Vashisht
  • 2,605
  • 1
  • 22
  • 23
  • Are you sure this removes the files from /usr/lib/jvm/jdk? [Because I don't think it does](https://askubuntu.com/a/911267/18665). Also, `purge` will also uninstall, so you don't need to use `remove` first. See `man apt-get | grep purge` – bmaupin Feb 08 '18 at 19:03
  • I have edited my answer. I think Oracle JDK is removed completely after following the steps given in the answer. If you don't think so, please provide an appropriate solution. – Gautam Vashisht Feb 09 '18 at 09:03
  • 2
    If I put `apt remove oracle-java8-jdk`, I get `The following new packages will be installed: oracle-java7-jdk`. But I do not want Java 7. `oracle-java8-installer` is not available. – Timo Mar 04 '18 at 16:42
  • Why does it install another version of Java? – chx101 Apr 07 '21 at 17:33