I'm trying to package an RPM that requires any Java version above Java 8. The RPM works fine if there's no Java installed, or if JRE/JDK for 8 is installed. HOWEVER if I install OpenJDK 11, when I install my RPM it will try to install Java 8 again.

How do I get my RPM to detect that there's already a Java 11 installation which should be compatible with my package? I don't want my package to install Java 8 if I have Java 11 already!

I'm running Red Hat 7.5, but this also reproduces in CentOS7. I was able to reproduce this with a simple hello world package:

Name:       hello-world
Version:    1
Release:    1
Summary:    Most simple RPM package
License:    FIXME
Requires:   jre-headless >= 1.8

cat > hello-world.sh <<EOF
echo Hello world

mkdir -p %{buildroot}/usr/bin/
install -m 755 hello-world.sh %{buildroot}/usr/bin/hello-world.sh



Build with:

rpmbuild -ba hello-world.spec

Then install OpenJDK11: sudo yum -y install java-11-openjdk

Finally test my package: rpm -i --test <FILE>.rpm gives:

error: Failed dependencies:
        jre-headless >= 1.8 is needed by hello-world-1-1.x86_64

sudo yum localinstall <FILE>.rpm also tries to install Java8.

sudo yum deplist <FILE>.rpm suggests that java-11-openjdk should provide what I need:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.heanet.ie
 * extras: ftp.heanet.ie
 * updates: ftp.heanet.ie
package: hello-world.x86_64 1-1
  dependency: /usr/bin/bash
   provider: bash.x86_64 4.2.46-31.el7
  dependency: jre-headless >= 1.8
   provider: java-11-openjdk-headless.x86_64 1:11.0.ea.28-7.el7
   provider: java-11-openjdk-headless.i686 1:11.0.ea.28-7.el7
   provider: java-1.8.0-openjdk-headless.x86_64 1:
   provider: java-1.8.0-openjdk-headless.i686 1:
   provider: java-1.7.0-openjdk-headless.x86_64 1:

(Not sure why Java 7 is a provider of Java 8 either).

I tried setting requires to jre or java but no luck. Also I tried pre-installing java-11-openjdk-headless specifically, but it made no difference.

It seems like boolean dependencies might fix this, but sadly I can't guarantee my end-users have a recent enough version of rpm installed.

I'm not sure what I could be doing wrong?

How do I set a RPM package to require Java 8 or higher, whose dependencies are satisfied by Java 11?

1 Answer 1


For now, the OpenJDK 11 packages in RHEL 7 and 8 don’t provide java-headless, jre-headless, or any of the unversioned Java packages. (As I understand it, the reason is that OpenJDK 11 isn’t guaranteed to be a replacement for OpenJDK 8 maintaining compatibility in all cases.) This will change when OpenJDK 11 becomes the system JDK; you can try tracking this bug to be notified of changes.

Unfortunately I don’t think there is a way currently to allow an RPM package to depend on jre-headless and be installable with OpenJDK 11 only, without using boolean dependencies (and RHEL 8, effectively). A typical workaround would be to use a file requirement instead of a package requirement, but java-8-openjdk-headless and java-11-openjdk-headless don’t provide a common file which you can depend upon (and I don’t think file requirements can be versioned).

Your query suggests that jre-headless is satisfied by the OpenJDK 11 packages, but that’s because the early-access packages erroneously provided the default packages; so

yum whatprovides jre-headless

lists OpenJDK 8 and OpenJDK 11 packages, but the latter are no longer installable.

  • So it might be a problem with the headless? If I set my Requires to java or jre it still fails to recognise the installed java. Maybe I don't understand why deplist or whatprovides think that Java 11 provides the java/jre package?
    – jenny
    Mar 6, 2019 at 13:49
  • This affects all the default Java packages. OpenJDK 11 turns up in the query results because of a packaging error in earlier versions of the packages. (See my update for details.) Mar 6, 2019 at 14:09
  • So a "jre-headless" dependency will install or use the end-of-lifed java-1.7.0 (!?) or java-1.8.0 but not java-11 (LTS)? This seems wrong and unnecessary, especially since multiple can be installed and "alternatives" can change the one used.
    – jamshid
    Oct 6, 2020 at 4:52
  • @jamshid what would you suggest? Remember that a major goal here is to preserve backwards compatibility: any program which works with jre-headless based on OpenJDK 8 must continue doing so, with no administrator configuration. Oct 6, 2020 at 5:17
  • idk it's just a frustrating situation when jre-headless can be used to mean a deprecated EOL java (1.7) but not the current LTS (11) released a couple of years ago. Locking the jre-headless dependency to legacy java releases does not prevent java 11 from being installed or made the default. I guess packages would have to provide separate rpm's for different java versions they support. e.g. maven-java-1.8 and maven-java-11 (centosfaq.org/centos/…) to avoid installing multiple JREs.
    – jamshid
    Oct 8, 2020 at 3:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .