Linux distribution: Red Hat Enterprise Linux Server release 6.10 (Santiago)

I need to uninstall all old versions of Java in my server.
I have the list of java paths, example:


I can find the pacakage owning this file by:

rpm -qf /usr/lib/jvm/java-1.8.0-openjdk-

Now, how to find all packages depending on java-1.8.0-openjdk-headless- , so that I can see whether it is safe to remove the package ?

Below command says no other packages depends on this openjdk package (Ref: Question-166343):

rpm -q --whatrequires  java-1.8.0-openjdk-headless-
no package requires java-1.8.0-openjdk-headless-

But, mysql-connector-java depends on this package.
Reason: rpm --whatrequires option's argument is CAPABILITY provided by a package , not package name and searching using CAPABILITY is not straightforward.

Below command was also not returning any results:

repoquery --requires --resolve --recursive java-1.8.0-openjdk-headless-

So, is there any simple way to identify all rpm packages which depends on a particular package?
By package , I mean java-1.8.0-openjdk-headless- (not java-1.8.0-openjdk-headless)

  • Did you install the java package via yum? Mar 28 '19 at 0:43
  • Yes. Installed via yum.
    – penguin
    Mar 28 '19 at 0:44
  • Add the script that you have so far to your question. Mar 28 '19 at 2:06
  • I see in other questions the "yum deplist" option; alternatively, you could run a test-remove: yum --assumeno ... or rpm --test ...
    – Jeff Schaller
    Mar 28 '19 at 2:26
  • @JeffSchaller yum deplist would show the packages on which it depends but not what depends on the package itself. Mar 28 '19 at 2:49

Try this,

Normally rpm -e doesn't uninstall a package if there are other packages that are dependent on this package [ of course --nodeps can be used to by pass this ]. As @JeffSchaller mentioned rpm -e can also be used in conjunction with --test to see if there are any error: Failed dependencies:

--test Don’t really uninstall anything, just go through the motions.  Useful in conjunction with the -vv option for debugging.

rpm -e -vv <package_name> -- check for error: Failed dependencies:


rpm -e -vv --test <package_name> -- check for error: Failed dependencies:

For more refer man rpm

  • An example I used: rpm -e mysql --test -vv 2>&1 | grep 'Failed dependencies'
    – penguin
    Mar 28 '19 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.