How to uninstall JDK
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:
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 :).
Related videos on Youtube
giacomotb
Updated on September 18, 2022Comments
-
giacomotb over 1 year
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
andjavac -version
Here any information: The
dpkg --list | grep -i jdk
command gives nothingThe 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?
-
Avinash Raj over 10 yearslist the folders inside
/usr/lib/jvm
-
giacomotb over 10 years@AvinashRaj done
-
Avinash Raj over 10 yearsdone means what?
-
giacomotb over 10 yearsI added to the question the list
-
-
giacomotb over 10 yearsok, how can I remove either JRE?
-
fikr4n over 10 years@giacomotb I've updated the answer. Hope it helps you.