How to uninstall java from ubuntu

How to uninstall Java from Ubuntu

Why do we need Java on our computers? There are tons of applications developed using the java environment, so we need to install java on our computers to make the java-based application run with no difficulty.

In many cases, you may need to remove java from your computer, such as installing the latest version of java or freeing up space from your machine. Installing Java on Ubuntu is pretty straightforward, but uninstalling it is a hard nut to crack for many folks. In this guide, we will learn how many versions of java are there, what distinguishes them, and how to erase them from your computer completely.

How
Sponsored
to check the type of Java on Linux (Ubuntu):

Before erasing java from your device, the first check is to identify what type of java you have on your PC. If you have installed java just to run the java applications, it would most probably “Java Runtime Environment (JRE).” Or, if you have installed java for development purpose, then you may have one of the following:

  • Open JDK
  • Oracle Java
See also  How to Install and Use Redshift in Ubuntu

The difference between “Open JDK” and “Oracle Java” is that the former is open-source, whereas the latter is license-based. Oracle Java is much better when it comes to performance and stability.

How to identify the Java version on Linux (Ubuntu):

Before uninstalling java from your PC, it is essential to know which version of java you have got. To check it launch terminal by pressing “ctrl+alt+t” and type the below-mentioned command:

$java -version

The above command will also indicate whether the version of java is “Open JDK” or “Oracle JDK.”

Standard output if the version is “OpenJDK”:

Standard output if the version is “Oracle Java”:

If you don’t have any version of java on your machine, the standard output will display it and provide some commands to install it.

How to switch versions of Java on Linux (Ubuntu):

Interestingly, you can have more than one versions of java on your device, and you can check and switch any of them by using the command mentioned below:

See also  You can now Test Ubuntu 24.04 Desktop Installer in Web Browser
$sudo update-alternatives –config java

The above command is displaying the different versions of java I have on my PC. To switch, simply type the number and press “Enter.”

How to check the installation method of Java on Linux (Ubuntu):

In some cases, it is crucial to identify the method of installation of java. To check it, use the command:

Sponsored
$dpkg -l | grep openjdk

For oracle java use:

$dpkg -l | grep oracle-java

The above output will indicate whether the package is installed from an official repository or a third-party repository. The above screenshots are demonstrating that “Oracle Java” is installed using the third-party repository “Linux pricing,” whereas “OpenJDK” is installed using the official Ubuntu repository.

How to uninstall Java from Linux (Ubuntu):

In the above discussion, we learned that there are multiple versions of java; you can have all of them on your PC at a time and conveniently switch them. Various approaches can be used to delete java from ubuntu. To completely erase “OpenJDK,” use:

See also  How to Restore Google Chrome Tabs
$sudo apt purge openjdk-11*

Or

$sudo apt remove –autoremove openjdk-11*

And to remove oracle java use:

$sudo apt purge oracle-java16-*

Or

$sudo apt remove –autoremove oracle-java16-*

That’s it. Now you can verify it using the command:

$java -version

Conclusion:

Java is one of your PC needs since many applications are developed and published using a java environment. Installing java on ubuntu is a simple procedure, but it is no less than a hassle for many uninstalling since there are multiple versions of java. In this guide, we learned how to identify which version you have on your PC and completely uninstall it.

The rise of Python and security issues has hit the popularity of Java. However still, java is the third most popular language among developers, but for how long nobody knows, the concerns related to its security are still there.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply