[CentOS] Installing Maven with OpenJDK 11, without pulling OpenJDK 1.8

Mathieu Baudier

mbaudier at argeo.org
Sat Nov 23 07:24:21 UTC 2019


I am trying to create a container image which will build Java software with
Maven and Java 11 (rather focussing on CentOS 8 here).

When installing 'maven' with yum, 'java-1.8.0-openjdk-devel' is installed
as a dependency. If one then installs 'java-11-openjdk-devel', and use the
update-alternatives command for java and javac, everything works fine and
Maven uses Java 11 for the build.

But I would like to avoid shipping OpenJDK 1.8 with the image, since it
would uselessly double its size. An approach would be to install Maven
manually, but it feels better to use the provided package.

Looking at the spec file, I understand that the 'maven' package requires
'java-devel' without explicitly specifying a version.
Is there some way (configuration, yum option, alternative, etc.) to make
OpenJDK 11 satisfying this dependency?
Could the new modules / app stream approach of CentOS 8 help here?

This is of course a more general RPM / yum question, but I suspect that the
Java use case is a recurring one, as many of us are currently upgrading
from 1.8 to 11.

Thanks in advance for hints, or telling me that there is no way to achieve


More information about the CentOS mailing list