Search

Chapter 3. Selecting an installed Red Hat build of OpenJDK version for a specific application

download PDF

Some applications require a specific Red Hat build of OpenJDK version to run. If multiple versions of Red Hat build of OpenJDK are installed on the system using the yum package manager or portable bundle, you can select a Red Hat build of OpenJDK version for each application where necessary by setting the value of the JAVA_HOME environment variable or using a wrapper script.

Prerequisites

  • Multiple versions of Red Hat build of OpenJDK installed on the machine.
  • Ensure that the application you want to run is installed.

Procedure

  1. Set the JAVA_HOME environment variable. For example, if Red Hat build of OpenJDK 17 was installed using yum:

    $ JAVA_HOME=/usr/lib/jvm/java-17-openjdk

    Note

    The symbolic link java-17-openjdk is controlled by the alternatives command.

  2. Do one of the following:

    • Launch the application using the default, system-wide configuration.

      $ mvn --version
      Apache Maven 3.5.4 (Red Hat 3.5.4-5)
      Maven home: /usr/share/maven
      Java version: 11.0.9, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.el8_0.x86_644/jre
      Default locale: en_US, platform encoding: UTF-8
      OS name: "linux", version: "4.18.0-144.el8.x86_64", arch: "amd64", family: "unix"
    • Launch the application specifying the JAVA_HOME variable:

      $ JAVA_HOME=/usr/lib/jvm/java-17-openjdk-17.0.0.0.35-4.el8.x86_64/ mvn --version
      
      Apache Maven 3.5.4 (Red Hat 3.5.4-5)
      Maven home: /usr/share/maven
      Java version: 17, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-17-openjdk-17.0.0.0.35-4.el8.x86_64
      Default locale: en_US, platform encoding: UTF-8
      OS name: "linux", version: "4.18.0-305.19.1.el8_4.x86_64", arch: "amd64", family: "unix"
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.