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

Here any information: The dpkg --list | grep -i jdk command gives nothing

The command java -version gives:

The program 'java' can be found in the following packages:
* default-jre
* gcj-4.6-jre-headless
* gcj-4.7-jre-headless
* openjdk-7-jre-headless
* openjdk-6-jre-headless
Try: sudo apt-get install <selected package>

The command javac -version gives this:

`TThe program 'javac' can be found in the following packages:
* default-jdk
* ecj
* gcj-4.6-jdk
* gcj-4.7-jdk
* openjdk-7-jdk
* openjdk-6-jdk
Try: sudo apt-get install <selected package>

if I run ls /usr/lib/jvm it says that there isn't such directory.

I would like to remove JDK and JRE before install packages. How can I do that?


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.


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:

sudo apt-get autoremove gcj-4.6-jre-headless gcj-4.7-jre-headless openjdk-6-jre-headless openjdk-7-jre-headless

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


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .