Linux how to find installed package name of Java and remove it

The tip below applies to systems that use the “dnf” package manager, e.g. RedHat 8 and AlmaLinux.

1. Find installed package based on wildcard name

You can use the following command to search all of the installed packages based on a wildcard name. For example, if we wish to find the package name that provides “java”, we can use the following command:

[lanedirt@linux01 ~]$ dnf list installed | grep -i java

This will give the following output:

java-1.8.0-openjdk-headless.x86_64            1:1.8.0.342.b07-2.el8_6                     @rhel-8-for-x86_64-appstream-rpms
javapackages-filesystem.noarch                5.3.0-1.module+el8+2447+6f56d9a6            @rhel-8-for-x86_64-appstream-rpms
mariadb-java-client.noarch                    2.2.5-3.el8                                 @rhel-8-for-x86_64-appstream-rpms
tzdata-java.noarch                            2022c-1.el8                                 @rhel-8-for-x86_64-appstream-rpms

As you can see, the first line in the output above shows the full name of the Java package that is installed.

2. (Optionally) remove package

You can remove a package with the following command (replace “[package_name]” with the name of the package to uninstall):

sudo dnf remove [package_name]

So in order to uninstall the Java package, we provide the full package name as indicated by the output in step #1:

sudo dnf remove java-1.8.0-openjdk-headless.x86_64

Hope this helped you. Good luck!

By Leendert de Borst

Freelance software architect with 10+ years of experience. Expert in translating complex technical problems into creative & simple solutions.

Leave a comment

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