Core Java

How to Uninstall Java for Windows 10

We will look at how to uninstall and remove Java completely from a Windows 10 system through tools. Invented by James Gosling, Java is an extremely popular, object-oriented programming language. The first version came out in 1996. Since then, there have been many versions of Java released. In this article, we will learn why and how to uninstall older versions of Java from a Windows 10 system.

1. Introduction

A new version of Java comes roughly every 6 months (prior to Java 8, this cycle was about 2-3 years). The newer versions contain fixes for issues in the earlier version, newer features, classes, and packages. Oracle recommends upgrading to the newer versions and uninstalling the older one.

1.1 Why should I uninstall Java versions which are old?

Before we see the steps to uninstall, we will first understand why keeping and using older versions of Java is dangerous.

We highly recommend that you uninstall all older versions of Java from your system.
Keeping old versions of Java on your system presents a serious security risk.
Uninstalling older versions of Java from your system ensures that Java applications will run with the latest security and performance improvements on your system.

Oracle on Java.com

Every new Java version releases fixes related to security and bugs from the older version. Using an older version of Java poses serious security threats. Flashback which affected Apple Macs is the most dramatic example of the security threat of old Java versions.

2. Why does Java not Uninstall the older version when I upgrade?

Java lets you install more than one version of Java on a system. The user can choose which version to run their Java application with. So, Java itself does not uninstall the earlier versions while upgrading. However, Oracle does not recommend this as it leaves your system open to security leaks.

2.1 Why would I need to run multiple versions of Java?

  • Java generally provides back-compatibility i.e. all the features that worked in the earlier version will work in the same way in the next version as well.
  • However, at times, some features of java do not work the same way as the older version due to changes in the code.
  • Also, some features may be deprecated in the newer version of Java. Example: Applets were deprecated in Java 9 and later removed from Java 11 onwards. So, if we have an application that relies on these deprecated/removed features, we will require an older version of Java.
  • In some cases, some legacy applications specify that they require a certain version of Java to run. In this case, as well we would require an older version.

3. How do I check which Java versions are installed on my system?

We can check the installed Java versions using 2 methods.

3.1 In the Program Files

When installed using the executable, Java is installed in either the Program Files or Program Filesx86. To check the installed versions.

  • Open the Windows Explorer.
  • Navigate to the path: C:/Program Files OR C:/Program Filesx86
  • Check for the folder named: Java.
  • In this folder, you will see the Java Development Kit (JDK) and/or Java Runtime Environment (JRE) installed on your system including the version numbers. For example I have Java version 7 (jdk1.7.0_80), Java version 8 (jre1.8.0_261), Java version 11 (jdk-11.0.8) an Java version 14 (jdk-14.0.2) installed on my system.
Uninstall Java - Installed java versions in program files
Installed java versions

3.2 Using the “where” command

The other way to check is using the “where” command in the Command Prompt.

  • Open the Command Prompt by typing cmd in the “Type here to search” box and click on the first option.
  • Another way is to press the Windows icon + R on the keyboard to open run and then type cmd.
  • Then type in where command. This will show the path all the different versions of java executables present in the system. (They need to be added to the classpath)
Uninstall Java - output of the where command
Where command

4. How do I uninstall the Older versions of Java?

There are 3 methods with which we can uninstall Java on our system.

4.1 Using the Java uninstall tool

Oracle provides the Java uninstall tool for removing Older versions of Java in the system. Go to the page, accept the Terms and download the JavaUninstallTool.exe file. Once downloaded we need to run it and follow the steps in the tool. The output should be similar to the image.

java uninstall tool steps
Java uninstall tool steps

4.2 Uninstall through the Control Panel

Java versions installed using Oracle JDK are listed under the Programs list in the Control Panel and can be uninstalled from there.

  1. In the search box type “Programs”.
  2. Select the “Add or remove programs” option. This opens the path <Control Panel\Programs\Programs and Features>
  3. In the Search List, type Java. This should show you all the Java versions installed on the System.
  4. Click on the uninstall button for the version you want to uninstall.
Uninstall a Java version using the Control Panel
Uninstall a Java version

4.3 OpenJDK uninstall

For uninstalling OpenJDK java installs, simply delete the extracted folder for Java.

5. How to remove Java completely from my system?

To remove all versions of Java installed on the system, repeat the steps for “Uninstall Java through the Control Panel.” That we have seen for removing older versions of Java. Repeat the steps for every installed version of Java. Example: On my system I would have to repeat twice because there are 2 versions Java version 11 and Java version 14 installed on my system.

If the Java versions installed are OpenJDK versions, delete the extracted folders.

6. Clearing the PATH variable

Even after the java version is uninstalled from the system, most times the entry in the PATH variable remains as-is. While not essential, it is always a good practice to clear out the deleted Java version paths from the PATH variable.

  1. In the type box, type “Environment Variables” and select the first option.
  2. Open the Environment Variables and select the “PATH” variables from the System variables list and click on “Edit”.
  3. In the environment variables, remove all the Java Paths for the versions we have removed.
  4. Repeat the same steps for the PATH variable in the “User variables” as well.
clearing the PATH variable
Clearing uninstalled java path form the PATH variable.

7. What if a Java uninstall fails?

In the rare scenario that a Java uninstall fails for any reason, Oracle recommends using the Microsoft Utility to correct the registry entries. Alternatively, we can correct the registry entries manually too. For more details, please check here.

8. Verify successful un-installation

To check if we have uninstalled Java correctly we have three ways.

8.1 Through the Control Panel

Once all the versions of Java have been uninstalled successfully, there is no entry in the List of Programs for Java.

  • Type “Programs” in the search box.
  • Select the “Add or remove programs” which opens the path: Control Panel\Programs\Programs and Features
  • In the Search, type “Java”. It should not return any results.
Uninstall Java - No Java in Programs
No Java in Programs

8.2 Using the java -version command

Open the Command Prompt and type in java -version command. It gives give a message : “Java is not recognized.” . This means that Java is not installed on our system.

No Java installed on machine
No Java installed on machine

8.3 Using the where command

  • The other way to check is using the where command in the Command Prompt.
  • Open the Command Prompt by typing cmd in the “Type here to search” box and click on the first option.
  • Another way is to press the “Windows icon” + R on the keyboard to open run and then type cmd.
  • It should return an error message saying “Could not find the files for the given pattern(s)”.
where output when no java installed
where output when no java installed

9. Summary

In the article, we learned how and why to uninstall older versions of Java from a Windows system. We also learned how remove Java completely. Further, we can also Disable Java on web browsers used on the Windows system. Visit the Oracle Java page for instructions to disable java.

Reshma Sathe

I am a recent Master of Computer Science degree graduate from the University Of Illinois at Urbana-Champaign.I have previously worked as a Software Engineer with projects ranging from production support to programming and software engineering.I am currently working on self-driven projects in Java, Python and Angular and also exploring other frontend and backend technologies.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
PHil
PHil
3 years ago

Thanks – very thorough and useful!!

pinsara chandika
pinsara chandika
3 years ago

This article was very helpful. Highly recommend

Back to top button