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...