How to uninstall Oracle JDK in Ubuntu 16.04 LTS [duplicate]

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.


Solution 1:

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.