0

I want to check if java-11-headless is installed. java-11-headless is a virtual package and it is provided e.g. by java-11-openjdk-headless.x86_64 package. I do not care what exactly package provides java-11-headless I only want to check if java-11-headless is installed.

I googled my issue and all answers concern checking certain package (e.g. java-11-openjdk-headless.x86_64) , not virtual package (java-11-headless).

As you can see below java-11-openjdk-headless.x86_64 is isnalled:

[root@21b70cb5fc59 /]# rpm -q java-11-openjdk-headless.x86_64
java-11-openjdk-headless-11.0.16.1.1-1.el7_9.x86_64
[root@21b70cb5fc59 /]# echo $?
0 

[root@21b70cb5fc59 /]# yum list installed java-11-openjdk-headless.x86_64
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: artfiles.org
 * extras: centos.bio.lmu.de
 * updates: centos.intergenia.de
Installed Packages
java-11-openjdk-headless.x86_64

Unfortunately I do not know how to check if java-11-headless is installed.

[root@21b70cb5fc59 /]# rpm -q java-11-headless
package java-11-headless is not installed
[root@21b70cb5fc59 /]# echo $?
1


[root@21b70cb5fc59 /]# yum list installed java-11-headless
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: artfiles.org
 * extras: centos.bio.lmu.de
 * updates: centos.intergenia.de
Error: No matching Packages to list
[root@21b70cb5fc59 /]# echo $?
1
Mariusz
  • 101
  • how about `yum list installed | egrep java-11\.\*headless` is that OK for you? – Robert Longson Oct 25 '22 at 08:14
  • In my case it should work but it is possible that there is some package that provides java-11-headless and does not meet your check. I would like to have more generic solution. – Mariusz Oct 25 '22 at 08:21
  • you can adjust the egrep but you're going to need to have some idea what you're looking for. – Robert Longson Oct 25 '22 at 08:23

0 Answers0