How to Install Default JDK in Linux Ubuntu OS ?


Java is a versatile programming language that powers a plethora of applications globally. If you’re venturing into Java development using Ubuntu, the Java Development Kit (JDK) is crucial. Here’s a guide to help you seamlessly install the JDK and set up environmental variables.


  1. An Ubuntu-powered computer.
  2. Sudo privileges.

Step-by-Step Guide

  1. Updating the Package Repository Ensure you have the most recent package listings:
ubuntu@Rushi-InfoTech:~$ sudo apt-get update
  1. Installing the Default JDK Ubuntu’s default repositories offer a stable JDK version:
ubuntu@Rushi-InfoTech:~$ sudo apt-get install default-jdk
  1. Validating the Installation Confirm Java’s installation:
ubuntu@Rushi-InfoTech:~$ java -version

The terminal should return with the Java version installed.

How to Uninstall Default JDK in Linux Ubuntu OS ?


While Java Development Kit (JDK) is an essential tool for Java developers, there may be instances where you need to uninstall it, such as to make space, resolve conflicts, or install a different version. Whatever the reason, here’s a guide to help you safely remove the default JDK from your Ubuntu system.


  1. An Ubuntu-powered computer.
  2. Terminal or command-line access.
  3. Sudo privileges.

Step-by-Step Guide

  1. Identify the Installed JDK Before you can uninstall the JDK, it’s essential to know which version(s) you have installed. This can be done using the following command:
ubuntu@Rushi-InfoTech:~$ dpkg --list | grep -i jdk

This will display a list of all packages related to JDK that are installed on your system.

  1. Uninstall the Default JDK Once you have identified the JDK package name from the list, you can proceed to uninstall it. Typically, the default JDK package is named default-jdk. Use the following command to remove it:
ubuntu@Rushi-InfoTech:~$ sudo apt-get purge default-jdk

If there are additional JDK related packages you wish to remove, simply replace default-jdk with the package name.

  1. Clean Up Additional Unused Dependencies After uninstalling the JDK, some dependencies might no longer be necessary. You can remove them to free up space:
ubuntu@Rushi-InfoTech:~$ sudo apt-get autoremove
  1. Verify Uninstallation To ensure the JDK has been successfully uninstalled:
ubuntu@Rushi-InfoTech:~$ java -version

If the JDK has been removed, the terminal should return a message indicating that java is not found or is not installed.


Managing the Java Development Kit (JDK) on Ubuntu is crucial for both budding developers and seasoned Java professionals. The ease with which Ubuntu allows users to handle software installations and removals, including the JDK, is commendable. By installing the JDK, you equip your system with the foundational tools necessary for Java development. Conversely, understanding how to uninstall it ensures that you maintain a clean and conflict-free development environment, especially when juggling multiple versions or when troubleshooting.

Whether you’re setting up your system for a new project, making space, or transitioning between JDK versions, this guide provides a concise roadmap. Ubuntu, with its user-friendly package management system, makes these tasks straightforward and hassle-free. As you progress in your Java journey, always ensure you have the right tools and versions aligned with your project needs. Happy coding!

Any queries pls contact us

Similar Posts

Leave a Reply

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