Say Goodbye to Java: Easy Step-by-Step Guide to Uninstalling Java in Ubuntu with Examples

Table of content

  1. Introduction
  2. Checking Java
  3. Removing Java
  4. Cleaning Up
  5. Testing Java Removal
  6. Troubleshooting
  7. Conclusion



Java is a popular programming language used for various purposes, including building web applications, developing mobile apps, and creating desktop software. However, as with any software, there may come a time when you no longer need it or want it on your system. If you're using Ubuntu, you can easily uninstall Java from your system. In this article, we'll provide you with step-by-step instructions for uninstalling Java in Ubuntu, along with some examples to help you understand the process better. Whether you're looking to free up some space on your system or simply don't need Java for your current projects, this guide will help you say goodbye to Java in Ubuntu quickly and easily.

Checking Java

Before embarking on the process of uninstalling Java, you may want to check whether it is installed on your Ubuntu system. Here are some simple steps to check whether Java is installed on your machine:

  1. Open the terminal by pressing Ctrl + Alt + T.

  2. Type the following command in the terminal:

    java -version

    This command will show you the version of Java installed on your system, if any.

  3. If you see a message that says "The program 'java' can be found in the following packages", it means that Java is not installed on your system.
    In this case, you do not need to uninstall Java since it is not installed.

  4. If you see a version number displayed, then Java is installed on your system.

    java version "1.8.0_282"
    Java(TM) SE Runtime Environment (build 1.8.0_282-b08)
    Java HotSpot(TM) 64-Bit Server VM (build 25.282-b08, mixed mode)

    The above output shows that Java version 1.8.0_282 is installed on the system.

    The process of uninstalling Java may vary depending on the version of Java and the method used to install it. In the next section, we will explore different methods of uninstalling Java from Ubuntu.

    Removing Java

from your Ubuntu machine is a straightforward process that can be done in just a few steps. Here's a quick guide on how to uninstall Java from your Ubuntu system:

  1. Open a terminal window by pressing "Ctrl+Alt+T" or searching for "terminal" in the applications menu.

  2. Type the following command to check if Java is installed on your system:

    java -version

    If you see output that includes the version number of Java installed, then Java is installed on your machine.

  3. Next, type the following command to list all installed packages related to Java:

    dpkg --list | grep -i jdk

    This will display a list of all JDK packages installed on your system.

  4. To remove all JDK packages and related configuration files, type the following command:

    sudo apt-get remove --purge openjdk-*

    This will remove all JDK packages and related configuration files from your system.

  5. Finally, type the following command to remove any remaining configuration files or dependencies:

    sudo apt-get autoremove

    This command will remove any remaining configuration files or dependencies that are no longer needed.

That's it! You have now successfully removed Java from your Ubuntu machine. If you need to reinstall Java at a later time, simply follow the steps outlined in the official Ubuntu documentation.

Cleaning Up

After uninstalling Java, it is important to clean up any leftover files and dependencies to free up disk space and ensure optimal system performance. Here are some steps to follow:

  1. Remove any temporary files related to Java:

    sudo rm -r /var/cache/oracle-jdk*
    sudo rm -r /usr/lib/jvm/java*
  2. Delete any empty directories that were created during the uninstallation process:

    sudo rmdir /usr/lib/jvm
    sudo rmdir /usr/java
  3. Remove any remaining Java packages or libraries that may be causing conflicts:

    sudo apt autoremove
  4. Remove any Java-related environment variables:

    sudo nano /etc/environment

    Locate any lines that reference Java or its installation directory and remove them.

  5. Update the shared library cache to remove any references to Java:

    sudo ldconfig

These steps should ensure that Java has been completely uninstalled and any associated files or settings have been removed from your system.

Testing Java Removal

After following the steps outlined in the previous section, you may wish to test that Java has been successfully removed from your Ubuntu system. Here are a few ways to check if Java is still installed:

  • Open a terminal and type java -version. If Java is still installed, you will see the output of the Java version installed on your system. If Java has been successfully uninstalled, you will get an error saying "java: command not found".
  • Check the list of installed packages by typing dpkg --list. Look for any packages that begin with "openjdk" or "oracle-java". If you see any, Java is still installed on your system.
  • Alternatively, you can use the apt-cache search command to search for any Java-related packages that may still be installed. Type apt-cache search java or apt-cache search openjdk to see a list of packages. If you see any that appear to be Java-related, Java is still installed on your system.

If Java is still installed after following the steps in the previous section, you may need to repeat the process or seek additional help to fully remove Java from your Ubuntu system.


If you encounter any issues while uninstalling Java, here are some common steps you can take:

  • Double-check your commands: Make sure you are typing the correct commands and paying attention to any typos or errors. One small mistake could cause the entire process to fail.

  • Check for dependencies: Some programs may depend on Java, so make sure you are not uninstalling something that will break other applications. You can check dependencies using the apt-cache rdepends default-jre command.

  • Try using a package manager: If you are not comfortable with using the command line, you can try using a package manager like Synaptic or the Ubuntu Software Center to uninstall Java.

  • Reinstall Java: If you accidentally uninstall the wrong version of Java, you may need to reinstall it and start the process over again. Use the apt-get install default-jre command to reinstall Java.

  • Ask for help: If you are still having trouble, don't hesitate to ask for help in online forums or communities. Other Ubuntu users may have encountered the same issues and can offer advice or solutions.


In , uninstalling Java from your Ubuntu system is not a difficult task. By following the steps provided in this guide, you can easily remove Java from your machine without any hassle. It is important to remember that Java is an old technology and has many security vulnerabilities that can put your machine at risk. Therefore, it is always advisable to keep your system updated and remove any outdated software. Additionally, if you do need to use Java for specific applications or software, make sure to only download it from trusted sources and keep it updated with the latest security patches. By taking these simple steps, you can ensure that your system is secure and up-to-date with the latest technology.

As a developer, I have experience in full-stack web application development, and I'm passionate about utilizing innovative design strategies and cutting-edge technologies to develop distributed web applications and services. My areas of interest extend to IoT, Blockchain, Cloud, and Virtualization technologies, and I have a proficiency in building efficient Cloud Native Big Data applications. Throughout my academic projects and industry experiences, I have worked with various programming languages such as Go, Python, Ruby, and Elixir/Erlang. My diverse skillset allows me to approach problems from different angles and implement effective solutions. Above all, I value the opportunity to learn and grow in a dynamic environment. I believe that the eagerness to learn is crucial in developing oneself, and I strive to work with the best in order to bring out the best in myself.
Posts created 1858

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top