How to Remove/Uninstall (Oracle Java & openJDK) on Linux

Most of us believe that it is difficult to remove/uninstall (Oracle Java & openJDK) from Linux box.

Today i am going to show how easy it is. As per my experience, i have installed JAVA many times in different distributions and removed/uninstalled safely without any issue.

You can also feel the same by checking few things before removing JAVA from linux box. In this article I’m clearly explaining what are the things you need to check before removing JAVA.

[ac-box color=”lgreen”]


1) Check current version of java

Check the installed version of java on your system, using the below command.

$ java -version
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)

2) Check, how many java versions are installed

Use the below command to check, how many java versions are installed on your system.

$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
  0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1072      auto mode
  1            /opt/jdk1.8.0_20/bin/java                        2         manual mode
  2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
* 3            /usr/lib/jvm/java-7-oracle/jre/bin/java          1072      manual mode

Press enter to keep the current choice[*], or type selection number:

The output clearly shows, i have installed three (Oracle java 7 & 8, openjdk 7) JAVA versions in my system. First we need to check JAVA installation method, like (Manual, rpm, Distribution repository or Thirdparty repository) before proceeding uninstall.

  • OpenJDK : Everybody using Distribution repository
  • Oracle JAVA : Manual or Thirdparty repository or rpm

3a) Check, how JAVA installed on Debian based systems

Use the below list of commands to check, how JAVA installed on Ubuntu/LinuxMint/Debian systems.

[Verifying OpenJDK installation method in Ubuntu/LinuxMint/Debian]

$ java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

[Verifying OpenJDK source in Ubuntu/LinuxMint/Debian]

$ dpkg -l | grep openjdk
ii  openjdk-7-jdk:amd64                      7u71-2.5.3-0ubuntu1            amd64        OpenJDK Development Kit (JDK)
ii  openjdk-7-jre:amd64                      7u71-2.5.3-0ubuntu1            amd64        OpenJDK Java runtime, using Hotspot JIT
ii  openjdk-7-jre-headless:amd64             7u71-2.5.3-0ubuntu1            amd64        OpenJDK Java runtime, using Hotspot JIT (headless)

[Verifying Oracle JAVA 7 installation method in Ubuntu/LinuxMint/Debian]

$ dpkg -l | grep oracle-java
ii  oracle-java7-installer                7u72+7u60arm-0~webupd8~2       all      Oracle Java(TM) Development Kit (JDK) 7

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

17 Comments on “How to Remove/Uninstall (Oracle Java & openJDK) on Linux”

  1. im on kalilinux 2020.4 i installed java 11.0.9 and java jdk 8 u217
    when i write java -version
    lzh:permission denied java
    it’s not about root there is another errorr help me plz

  2. I see you don’t monetize your website, i think there is one opportunity to earn additional cash on your page,
    search in google for: idol4jp makes money

  3. linux-bi4s:~ # java -version
    If ‘java’ is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf java
    linux-bi4s:~ # update-alternatives –config java
    update-alternatives: error: no alternatives for java
    linux-bi4s:~ # rpm -qa | grep java
    linux-bi4s:~ # rpm -qa | grep jdk
    linux-bi4s:~ # rpm -e java-1_7_0-openjdk-
    error: Failed dependencies:
    jre-64 > 1.5 is needed by (installed) libreoffice-writer-extensions-
    jre-64 > 1.5 is needed by (installed) libreoffice-calc-extensions-
    linux-bi4s:~ # rpm -e java-1_7_0-openjdk-headless-
    error: Failed dependencies:
    java-1_7_0-openjdk-headless = is needed by (installed) java-1_7_0-openjdk- is needed by (installed) java-1_7_0-openjdk- is needed by (installed) java-1_7_0-openjdk- is needed by (installed) java-1_7_0-openjdk- is needed by (installed) java-1_7_0-openjdk- is needed by (installed) java-1_7_0-openjdk-
    linux-bi4s:~ #

  4. How do I UNINSTALL Java 9? It is causing errors when I download updates,& I would love to UNINSTALL it without having to reinstall Linux Mint. Google is ABSOLUTELY USELESS in trying to find this answer.

  5. Magesh,
    Many thanks for this tutorial. It worked perfectly on Linux Mint 17.1 for me. Now I would like to re-install Java, latest version. Do you also have a tutorial for that?

  6. I have uninstalled Java 7 jdk and my GUI crashed and linux mint boots into console mode. Is the only way to get back to normal to reinstall Java? I believe I uninstalled my jre and that is why this has happened. Can you help?

Leave a Reply

Your email address will not be published. Required fields are marked *