It has been seen that by mistake user tend to install OpenJDK instead of Oracle JDK while configuring the server. In order to remove OpenJDK and Install Oracle JDK in Linux, follow the following steps.

First you can check which JDK is installed by entering following command in the terminal

  • java -version

To remove the JDK run following command in RPM based linux

  • sudo yum remove jdk
  • sudo yum -y remove java* 

To remove JDK run following command in Debian based linux

  • apt-get remove jdk*
  • apt-get remove java*
  • sudo update-alternatives --remove-all java
  • sudo update-alternatives --remove-all javac
  • sudo update-alternatives --remove-all javaws
  • sudo rm -rf /usr/lib/jvm/*

After executing the above command execute "java -version" to verify the JAVA is completely uninstalled.

Now you can follow the steps described in Installing JDK in Debian or RPM based Linux.