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

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

$ sudo update-alternatives --config 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
  • OpenJDK : In OpenJDK (Java -version) output itself cleary shows that we have installed it using Ubuntu repository.
  • Oracle JAVA 7 : While grep, we can identify. It was installed using (webupd8) repository.
  • Oracle JAVA 8 : In JAVA alternatives clearly shows, We have installed Oracle JAVA 8 manually because everybody using /opt folder for manual software installation.

3b) Check, how JAVA installed on RPM based systems

Use the below list of commands to check, how JAVA installed on CentOS/Fedora/RHEL systems.

[Verifying OpenJDK installation method in CentOS/Fedora/RHEL]

$ java -version
java version "1.7.0_71"
OpenJDK Runtime Environment (rhel-2.5.3.2.el6_6-x86_64 u71-b14)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

[Verifying OpenJDK source in CentOS/Fedora/RHEL]

$ rpm -qa | grep java
java-1.7.0-openjdk-1.7.0.71-2.5.3.2.el6_6.x86_64

[Verifying Oracle JAVA installed Method in CentOS/Fedora/RHEL]

$ rpm -qa | grep jdk
jdk1.8.0_25-1.8.0_25-fcs.x86_64
  • OpenJDK : In OpenJDK (Java -version) output itself cleary shows we have installed using CentOS repository (rpm).
  • Oracle Java 8 : While greping, we can identify. It was installed manually using (rpm) method.

4) Remove/Uninstall JAVA in Linux

Use the below list of command’s to Remove/Uninstall JAVA in Linux. Based on Point 3a & 3b.

[Remove/Uninstall Openjdk in Ubuntu/LinuxMint/Debian]

[Remove/Uninstall Openjdk]
$ sudo apt-get purge openjdk-7-*

[Remove/Uninstall Oracle Java 7]
$ sudo apt-get remove oracle-java7-installer

[Remove/Uninstall Oracle Java 8]
$ cd /opt
$ sudo rm -Rf jdk1.8.0_20

[Remove/Uninstall Openjdk in CentOS/RHEL/Fedora]

[Remove/Uninstall Openjdk]
$ rpm -e (grep output from 3b)
$ sudo rpm -e java-1.7.0-openjdk-1.7.0.71-2.5.3.2.el6_6.x86_64

[Remove/Uninstall Oracle Java 8]
$ sudo rpm -e jdk1.8.0_25-1.8.0_25-fcs.x86_64

5) Check JAVA Version

We have completely removed openJDK & Oracle JAVA from my system and going to re check to confirm, there is no JAVA version has been installed.

$ java -version
bash: /usr/bin/java: No such file or directory

The output clearly shows, there is no java package installed in the system.

Today, I’m so happy because i have covered the headache topic, where most of the user getting strougle..enjoy..)

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

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