Today I installed Android Studio but when I opened it raised the error:

'tools.jar' seems to be not in Android Studio classpath.
Please ensure JAVA_HOME points to JDK rather than JRE.

I have already installed JDK from the Ubuntu Software Center but I decide to remove it and reinstall it by command-line following these instruction. The guide that I follow for remove it is that answer, this and this. How can I uninstall it? I know that it is installed for the output of java -version and javac -version

1 Answer
1

I see that you've already uninstalled the JDK (Java Development Kit) and JRE (Java Runtime Environment). The openjdk-*-jre* is actually the JRE (Java Runtime Environment) of OpenJDK, the JDK of OpenJDK is something like openjdk-*-jdk.

When you run java and the system says The program 'java' can be found in the following packages: ..., it means you have not installed any JRE yet. When you run javac and the system says The program 'javac' can be found in the following packages: ..., it means you have not installed any JDK yet.

-or-

Maybe you have installed one, but you have not properly set it up. This happens if you install JRE/JDK without using package manager, i.e. not using apt-get, aptitute, Software Center, Synaptic Package Manager, etc. If you install JRE/JDK by using package manager, I am sure that you can run java or javac, i.e. if you run java -version or javac -version the version you have installed will be printed instead of a suggestion of package you need to install. However, it is not the case. Let's say that you have uninstall any JRE/JDK.

How to uninstall

This is the answer about how to uninstall (because the question is "How to uninstall JDK"), just ignore it if you have uninstalled it.

The simplest way is to use terminal. First, type:

apt-get autoremove <list-of-package-names> -s

It will do a simulation, so you can see what packages will be removed. If you are sure about what you do, just run the command without -s parameter and use sudo. For example:

DANGER! Pay attention on the list of package you are about to remove (you will see it before confirming the actual execution), because it will also remove packages that depend on the package in the list (parameters after sudo apt-get). So, any application that needs JRE/JDK to run will also be removed. I have warned you :).

@giacomotb: As Fabby would say: If this answers your question, don't forget to click the grey check-mark under the abysmally small at the left of this text, which means "yes, this answer is valid"! ;-)
–
ToroidalFeb 7 at 19:04