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.

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

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

  • 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

  • Supratik Nag

    Hi Magesh,
    Please see my post here. How do I remove Java 7?

  • Supratik Nag

    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
    timezone-java-2014h-1.1.noarch
    java-1_7_0-openjdk-1.7.0.71-1.1.x86_64
    libjavascriptcoregtk-1_0-0-2.4.6-1.4.x86_64
    java-1_7_0-openjdk-headless-1.7.0.71-1.1.x86_64
    libjavascriptcoregtk-3_0-0-2.4.6-1.4.x86_64
    libjavascriptcoregtk-4_0-18-2.6.1-1.1.x86_64
    java-binfmt-misc-1.4-4.1.3.x86_64
    linux-bi4s:~ # rpm -qa | grep jdk
    java-1_7_0-openjdk-1.7.0.71-1.1.x86_64
    java-1_7_0-openjdk-headless-1.7.0.71-1.1.x86_64
    linux-bi4s:~ # rpm -e java-1_7_0-openjdk-1.7.0.71-1.1.x86_64
    error: Failed dependencies:
    jre-64 > 1.5 is needed by (installed) libreoffice-writer-extensions-4.3.2.2-1.3.x86_64
    jre-64 > 1.5 is needed by (installed) libreoffice-calc-extensions-4.3.2.2-1.3.x86_64
    linux-bi4s:~ # rpm -e java-1_7_0-openjdk-headless-1.7.0.71-1.1.x86_64
    error: Failed dependencies:
    java-1_7_0-openjdk-headless = 1.7.0.71-1.1 is needed by (installed) java-1_7_0-openjdk-1.7.0.71-1.1.x86_64
    libawt.so()(64bit) is needed by (installed) java-1_7_0-openjdk-1.7.0.71-1.1.x86_64
    libjava.so()(64bit) is needed by (installed) java-1_7_0-openjdk-1.7.0.71-1.1.x86_64
    libjava.so(SUNWprivate_1.1)(64bit) is needed by (installed) java-1_7_0-openjdk-1.7.0.71-1.1.x86_64
    libjvm.so()(64bit) is needed by (installed) java-1_7_0-openjdk-1.7.0.71-1.1.x86_64
    libjvm.so(SUNWprivate_1.1)(64bit) is needed by (installed) java-1_7_0-openjdk-1.7.0.71-1.1.x86_64
    linux-bi4s:~ #

  • Neeraj

    Good Job..

  • Sangeetha

    Great post. Thank you!

  • Roy Smith

    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.

    • @Roy,
      Can you tell me how you installed Java 9. So, that i can give a solution to remove.

  • Caio

    Userful!!! Thanks!

  • Ron Modesitt

    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?
    Ron

  • David Holloway

    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?

    • @David,
      I’m bit confusing because it wont affect GUI and there is no relationship with GUI & JRE. I guess it could be some other reason.

Close
Please support the site
By clicking any of these buttons you help our site to get better