How to remove Oracle JDK

It could be done like this:

  1. Remove the link:

    sudo update-alternatives --remove "java" "/usr/lib/jvm/jdk[version]/bin/java"    
    sudo update-alternatives --remove "javac" "/usr/lib/jvm/jdk[version]/bin/javac"    
    sudo update-alternatives --remove "javaws" "/usr/lib/jvm/jdk[version]/bin/javaws"
    
  2. Then, remove the package in the /usr/lib/jvm:

    sudo rm -r /usr/lib/jvm/jdk[version]
    

Note :

  • Change [version] with any version number that's contained in jdk folder's name, example: jdk[version] = jdk1.7.0_13.

  • If you are new to Linux, you should probably get familiar with the manual page. Lot of good stuff from there. Just go to the terminal and type man update-alternatives.


Run sudo update-alternatives --config java and choose an openjdk verion. Delete the oracle jdk files and if you need to uninstall openjdk too, do it with the Ubuntu Software Center.