Este contenido no está disponible en el idioma seleccionado.
Installing and using Red Hat build of OpenJDK 8 for RHEL
Abstract
Providing feedback on Red Hat build of OpenJDK documentation Copiar enlaceEnlace copiado en el portapapeles!
To report an error or to improve our documentation, log in to your Red Hat Jira account and submit an issue. If you do not have a Red Hat Jira account, then you will be prompted to create an account.
Procedure
- Click the following link to create a ticket.
- Enter a brief description of the issue in the Summary.
- Provide a detailed description of the issue or enhancement in the Description. Include a URL to where the issue occurs in the documentation.
- Clicking Submit creates and routes the issue to the appropriate documentation team.
Making open source more inclusive Copiar enlaceEnlace copiado en el portapapeles!
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.
Chapter 1. Red Hat build of OpenJDK 8 overview Copiar enlaceEnlace copiado en el portapapeles!
OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java Platform, Standard Edition (Java SE). The Red Hat build of OpenJDK is available in three versions: 8u, 11u, and 17u.
Packages for the Red Hat build of OpenJDK are made available on Red Hat Enterprise Linux and Microsoft Windows and shipped as a JDK and JRE in the Red Hat Ecosystem Catalog.
Chapter 2. Installing Red Hat build of OpenJDK 8 on Red Hat Enterprise Linux Copiar enlaceEnlace copiado en el portapapeles!
Red Hat build of OpenJDK is an environment for developing and running a wide range of platform-agnostic applications, from mobile applications to desktop and web applications and enterprise systems. Red Hat provides an open source implementation of the Java Platform SE (Standard Edition) called Red Hat build of OpenJDK.
Applications are developed using the JDK (Java Development Kit). Applications are run on a JVM (Java Virtual Machine), which is included in the JRE (Java Runtime Environment) and the JDK. There is also a headless version of Java which has the smallest footprint and does not include the libraries needed for a user interface. The headless version is packaged in the headless subpackage.
If you are unsure whether you need the JRE or the JDK, it is recommended that you install the JDK.
The following sections provide instructions for installing Red Hat build of OpenJDK on Red Hat Enterprise Linux.
You can install multiple major versions of Red Hat build of OpenJDK on your local system. If you need to switch from one major version to another major version, issue the following command in your command-line interface (CLI) and then following the onscreen prompts:
sudo update-alternatives --config 'java'
$ sudo update-alternatives --config 'java'
2.1. Installing a JRE on RHEL by using yum Copiar enlaceEnlace copiado en el portapapeles!
You can install Red Hat build of OpenJDK Java Runtime Environment (JRE) using the system package manager, yum.
Prerequisites
- Logged in as a user with root privileges on the system.
- Registered your local system to your Red Hat Subscription Management account. See the Registering a system using Red Hat Subscription Management user guide.
Procedure
Run the
yumcommand, specifying the package you want to install:sudo yum install java-1.8.0-openjdk
$ sudo yum install java-1.8.0-openjdkCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check that the installation works:
java -version
$ java -version openjdk version "1.8.0_322" OpenJDK Runtime Environment (build 1.8.0_322-b06) OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf the output from the previous command shows that you have a different major version of Red Hat build of OpenJDK checked out on your system, you can enter the following command in your CLI to switch your system to use Red Hat build of OpenJDK 8:
sudo update-alternatives --config 'java'
$ sudo update-alternatives --config 'java'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2. Installing a JRE on RHEL by using an archive Copiar enlaceEnlace copiado en el portapapeles!
You can install Red Hat build of OpenJDK Java Runtime Environment (JRE) by using an archive. This is useful if the Java administrator does not have root privileges.
To ease the upgrades for later versions create a parent directory to contain your JREs and create a symbolic link to the latest JRE using a generic path.
Procedure
Create a directory to where you want to download the archive file, and then navigate to that directory on your command-line interface (CLI). For example:
mkdir ~/jres cd ~/jres
$ mkdir ~/jres $ cd ~/jresCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Navigate to the Software Downloads page on the Red Hat Customer Portal.
- Select the latest version of Red Hat build of OpenJDK 8 from the Version drop-down list, and then download the JRE archive for Linux to your local system.
Extract the contents of the archive to a directory of your choice:
tar -xf java-1.8.0-openjdk-portable-1.8.0.322.b06-4.portable.jre.el7.x86_64.tar.xz -C ~/jres
$ tar -xf java-1.8.0-openjdk-portable-1.8.0.322.b06-4.portable.jre.el7.x86_64.tar.xz -C ~/jresCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a generic path by using symbolic links to your JRE for easier upgrades:
ln -s ~/jres/java-1.8.0-openjdk-portable-1.8.0.322.b06-4.portable.jre.el7.x86_64 ~/jres/java-8
$ ln -s ~/jres/java-1.8.0-openjdk-portable-1.8.0.322.b06-4.portable.jre.el7.x86_64 ~/jres/java-8Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the
JAVA_HOMEenvironment variable:export JAVA_HOME=~/jres/java-8
$ export JAVA_HOME=~/jres/java-8Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that
JAVA_HOMEenvironment variable is set correctly:printenv | grep JAVA_HOME
$ printenv | grep JAVA_HOME JAVA_HOME=~/jres/java-8Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteWhen installed using this method, Java will only be available for the current user.
Add the
bindirectory of the generic JRE path to thePATHenvironment variable:export PATH="$JAVA_HOME/bin:$PATH"
$ export PATH="$JAVA_HOME/bin:$PATH"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that
java -versionworks without supplying the full path:java -version
$ java -version openjdk version "1.8.0_322" OpenJDK Runtime Environment (build 1.8.0_322-b06) OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can ensure that
JAVA_HOMEenvironment variable persists for the current user by exporting the environment variable in~/.bashrc.
2.3. Installing Red Hat build of OpenJDK on RHEL by using yum Copiar enlaceEnlace copiado en el portapapeles!
You can install Red Hat build of OpenJDK using the system package manager, yum.
Prerequisites
- Log in as a user with root privileges.
- Registered your local system to your Red Hat Subscription Management account. See the Registering a system using Red Hat Subscription Management user guide.
Procedure
Run the
yumcommand, specifying the package you want to install:sudo yum install java-1.8.0-openjdk-devel
$ sudo yum install java-1.8.0-openjdk-develCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check that the installation works:
javac -version
$ javac -version javac 1.8.0_322Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.4. Installing Red Hat build of OpenJDK on RHEL by using an archive Copiar enlaceEnlace copiado en el portapapeles!
You can install Red Hat build of OpenJDK with an archive. This is useful if the Java administrator does not have root privileges.
To ease upgrades, create a parent directory to contain your JREs and create a symbolic link to the latest JRE using a generic path.
Procedure
Create a directory to where you want to download the archive file, and then navigate to that directory on your command-line interface (CLI). For example:
mkdir ~/jdks cd ~/Downloads
$ mkdir ~/jdks $ cd ~/DownloadsCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Navigate to the Software Downloads page on the Red Hat Customer Portal.
- Select the latest version of Red Hat build of OpenJDK 8 from the Version drop-down list, and then download the JDK archive for Linux to your local system.
Extract the contents of the archive to a directory of your choice:
tar -xf java-1.8.0-openjdk-portable-1.8.0.322.b06-4.portable.jdk.el7.x86_64.tar.xz -C ~/jdks
$ tar -xf java-1.8.0-openjdk-portable-1.8.0.322.b06-4.portable.jdk.el7.x86_64.tar.xz -C ~/jdksCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a generic path by using symbolic links to your JDK for easier upgrades:
ln -s ~/jdks/java-1.8.0-openjdk-portable-1.8.0.322.b06-4.portable.jdk.el7.x86_64 ~/jdks/java-8
$ ln -s ~/jdks/java-1.8.0-openjdk-portable-1.8.0.322.b06-4.portable.jdk.el7.x86_64 ~/jdks/java-8Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the
JAVA_HOMEenvironment variable:export JAVA_HOME=~/jdks/java-8
$ export JAVA_HOME=~/jdks/java-8Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that
JAVA_HOMEenvironment variable is set correctly:printenv | grep JAVA_HOME
$ printenv | grep JAVA_HOME JAVA_HOME=~/jdks/java-8Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteWhen installed using this method, Java will only be available for the current user.
Add the
bindirectory of the generic JRE path to thePATHenvironment variable:export PATH="$JAVA_HOME/bin:$PATH"
$ export PATH="$JAVA_HOME/bin:$PATH"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that
java -versionworks without supplying the full path:java -version
$ java -version openjdk version "1.8.0_322" OpenJDK Runtime Environment (build 1.8.0_322-b06) OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can ensure that
JAVA_HOMEenvironment variable persists for the current user by exporting the environment variable in~/.bashrc.
2.5. Installing multiple major versions of Red Hat build of OpenJDK on RHEL by using yum Copiar enlaceEnlace copiado en el portapapeles!
You can install multiple versions of Red Hat build of OpenJDK using the system package manager, yum.
Prerequisites
- A Red Hat Subscription Management (RHSM) account with an active subscription that provides access to a repository that provides the Red Hat build of OpenJDK you want to install.
- You must have root privileges on the system.
Procedure
Run the following
yumcommands to install the package:For Red Hat build of OpenJDK 17
sudo yum install java-17-openjdk
$ sudo yum install java-17-openjdkCopy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat build of OpenJDK 11
sudo yum install java-11-openjdk
$ sudo yum install java-11-openjdkCopy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat build of OpenJDK 8
sudo yum install java-1.8.0-openjdk
$ sudo yum install java-1.8.0-openjdkCopy to Clipboard Copied! Toggle word wrap Toggle overflow After installing, check the available java versions:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the current java version:
java -version
$ java -version openjdk version "1.8.0_322" OpenJDK Runtime Environment (build 1.8.0_322-b06) OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf the output from the previous command shows that you have a different major version of Red Hat build of OpenJDK checked out on your system, you can enter the following command in your CLI to switch your system to use Red Hat build of OpenJDK 8:
sudo update-alternatives --config 'java'
$ sudo update-alternatives --config 'java'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.6. Installing multiple major versions of Red Hat build of OpenJDK on RHEL by using an archive Copiar enlaceEnlace copiado en el portapapeles!
You can install multiple major versions of Red Hat build of OpenJDK by using the same procedures found in Installing a JRE on RHEL by using an archive or Installing Red Hat build of OpenJDK on RHEL 8 by using an archive using multiple major versions.
For instructions how to configure the default Red Hat build of OpenJDK version for the system, see Interactively selecting a system-wide Red Hat build of OpenJDK version on RHEL.
2.7. Installing multiple minor versions of Red Hat build of OpenJDK on RHEL by using yum Copiar enlaceEnlace copiado en el portapapeles!
You can install multiple minor versions of Red Hat build of OpenJDK on RHEL. This is done by preventing the installed minor versions from being updated.
Prerequisites
- Choose system-wide version of Red Hat build of OpenJDK from Non-interactively selecting a system-wide Red Hat build of OpenJDK version on RHEL.
Procedure
Add the
installonlypkgsoption in the/etc/yum.confdirectory to specify the Red Hat build of OpenJDK packages thatyumcan install but not update.installonlypkgs=java-<version>--openjdk,java-<version>--openjdk-headless,java-<version>--openjdk-devel
installonlypkgs=java-<version>--openjdk,java-<version>--openjdk-headless,java-<version>--openjdk-develCopy to Clipboard Copied! Toggle word wrap Toggle overflow Updates will install new packages while leaving the old versions on the system.
rpm -qa | grep java-1.8.0-openjdk
$ rpm -qa | grep java-1.8.0-openjdk java-1.8.0-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64 java-1.8.0-openjdk-1.8.0.322.b06-2.el8_5.x86_64Copy to Clipboard Copied! Toggle word wrap Toggle overflow The different minor versions of Red Hat build of OpenJDK can be found in the
/usr/lib/jvm/<minor version>files.For example, the following shows part of
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.8. Installing multiple minor versions of Red Hat build of OpenJDK on RHEL by using an archive Copiar enlaceEnlace copiado en el portapapeles!
Installing multiple minor versions is the same as Installing a JRE on RHEL by using an archive or Installing Red Hat build of OpenJDK on RHEL 8 by using an archive using multiple minor versions.
For instructions how to choose a default minor version for the system, see Non-interactively selecting a system-wide Red Hat build of OpenJDK version on RHEL.
Chapter 3. Debug symbols for Red Hat build of OpenJDK 8 Copiar enlaceEnlace copiado en el portapapeles!
Debug symbols help in investigating a crash in Red Hat build of OpenJDK applications.
3.1. Installing the debug symbols Copiar enlaceEnlace copiado en el portapapeles!
This procedure describes how to install the debug symbols for Red Hat build of OpenJDK.
Prerequisites
Installed the
gdbpackage on your local sytem.-
You can issue the
sudo yum install gdbcommand on your CLI to install this package on your local system.
-
You can issue the
Procedure
To install the debug symbols, enter the following command:
sudo yum debuginfo-install java-1.8.0-openjdk sudo yum debuginfo-install java-1.8.0-openjdk-headless
$ sudo yum debuginfo-install java-1.8.0-openjdk $ sudo yum debuginfo-install java-1.8.0-openjdk-headlessCopy to Clipboard Copied! Toggle word wrap Toggle overflow These commands install
java-1.8.0-openjdk-debuginfo,java-1.8.0-openjdk-headless-debuginfo, and additional packages that provide debug symbols for Red Hat build of OpenJDK 8 binaries. These packages are not self-sufficient and do not contain executable binaries.NoteThe
debuginfo-installis provided by theyum-utilspackage.To verify that the debug symbols are installed, enter the following command:
gdb which java
$ gdb which java Reading symbols from /usr/bin/java...Reading symbols from /usr/lib/debug/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-2.el8_5/bin/java-1.8.0.322.b06-2.el8_5.x86_64.debug...done. (gdb)Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2. Checking the installation location of debug symbols Copiar enlaceEnlace copiado en el portapapeles!
This procedure explains how to find the location of debug symbols.
If the debuginfo package is installed, but you cannot get the installation location of the package, then check if the correct package and java versions are installed. After confirming the versions, check the location of debug symbols again.
Prerequisites
Installed the
gdbpackage on your local sytem.-
You can issue the
sudo yum install gdbcommand on your CLI to install this package on your local system. - Installed the debug symbols package. See Installing the debug symbols.
-
You can issue the
Procedure
To find the location of debug symbols, use
gdbwithwhich javacommands:gdb which java
$ gdb which java Reading symbols from /usr/bin/java...Reading symbols from /usr/lib/debug/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-2.el8_5/bin/java-1.8.0.322.b06-2.el8_5.x86_64.debug...done. done. (gdb)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the following commands to explore the
*-debugdirectory to see all the debug versions of the libraries, which includejava,javac, andjavah:cd /usr/lib/debug/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-2.el8_5
$ cd /usr/lib/debug/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-2.el8_5Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The javac and javah tools are provided by the java-1.8.0-openjdk-devel package. You can install the package using the command: $ sudo debuginfo-install java-1.8.0-openjdk-devel.
3.3. Checking the configuration of debug symbols Copiar enlaceEnlace copiado en el portapapeles!
You can check and set configurations for debug symbols.
To get the list of the installed packages, enter the following command:
sudo yum list installed | grep 'java-1.8.0-openjdk-debuginfo'
$ sudo yum list installed | grep 'java-1.8.0-openjdk-debuginfo'Copy to Clipboard Copied! Toggle word wrap Toggle overflow If some debug information packages have not been installed, enter the following command to install the missing packages:
sudo yum debuginfo-install glibc-2.28-151.el8.x86_64 libgcc-8.4.1-1.el8.x86_64 libstdc++-8.4.1-1.el8.x86_64 sssd-client-2.4.0-9.el8.x86_64 zlib-1.2.11-17.el8.x86_64
$ sudo yum debuginfo-install glibc-2.28-151.el8.x86_64 libgcc-8.4.1-1.el8.x86_64 libstdc++-8.4.1-1.el8.x86_64 sssd-client-2.4.0-9.el8.x86_64 zlib-1.2.11-17.el8.x86_64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command if you want to hit a specific breakpoint:
gdb -ex 'handle SIGSEGV noprint nostop pass' -ex 'set breakpoint pending on' -ex 'break JavaCalls::call' -ex 'run' --args java ./HelloWorld
$ gdb -ex 'handle SIGSEGV noprint nostop pass' -ex 'set breakpoint pending on' -ex 'break JavaCalls::call' -ex 'run' --args java ./HelloWorldCopy to Clipboard Copied! Toggle word wrap Toggle overflow The above command completes the following tasks:
- Handles the SIGSEGV error as the JVM uses SEGV for stack overflow check.
-
Sets pending breakpoints to
yes. -
Calls the break statement in
JavaCalls::callfunction. The function to starts the application in HotSpot (libjvm.so).
3.4. Configuring the debug symbols in a fatal error log file Copiar enlaceEnlace copiado en el portapapeles!
When a Java application is down due to a JVM crash, a fatal error log file is generated, for example: hs_error, java_error. These error log files are generated in current working directory of the application. The crash file contains information from the stack.
Procedure
You can remove all the debug symbols by using the
strip -gcommand.The following code shows an example of non-stripped
hs_errorfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following code shows an example of stripped
hs_errorfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the following command to check that you have the same version of debug symbols and the fatal error log file:
java -version
$ java -versionCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can also use the
sudo update-alternatives --config 'java'to complete this check.Use the
nmcommand to ensure thatlibjvm.sohas ELF data and text symbols:nm /usr/lib/debug/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-2.el8_5/lib/server/libjvm.so-1.8.0.322.b06-2.el8_5.x86_64.debug
$ nm /usr/lib/debug/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-2.el8_5/lib/server/libjvm.so-1.8.0.322.b06-2.el8_5.x86_64.debugCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 4. Updating Red Hat build of OpenJDK 8 on RHEL Copiar enlaceEnlace copiado en el portapapeles!
The following sections provide instructions for updating Red Hat build of OpenJDK 8 on RHEL.
4.1. Updating Red Hat build of OpenJDK 8 on RHEL by using yum Copiar enlaceEnlace copiado en el portapapeles!
The installed Red Hat build of OpenJDK packages can be updated using the yum system package manager.
Prerequisites
- You must have root privileges on the system.
Procedure
Check the current Red Hat build of OpenJDK version:
sudo yum list installed "java*"
$ sudo yum list installed "java*"Copy to Clipboard Copied! Toggle word wrap Toggle overflow A list of installed Red Hat build of OpenJDK packages displays.
Installed Packages java-1.8.0-openjdk.x86_64 1:1.8.0.322.b06-2.el8_5 @rhel-8-for-x86_64-appstream-rpms java-11-openjdk.x86_64 1:11.0.14.0.9-2.el8_5 @rhel-8-for-x86_64-appstream-rpms java-17-openjdk.x86_64 1:17.0.2.0.8-4.el8_5 @rhel-8-for-x86_64-appstream-rpms
Installed Packages java-1.8.0-openjdk.x86_64 1:1.8.0.322.b06-2.el8_5 @rhel-8-for-x86_64-appstream-rpms java-11-openjdk.x86_64 1:11.0.14.0.9-2.el8_5 @rhel-8-for-x86_64-appstream-rpms java-17-openjdk.x86_64 1:17.0.2.0.8-4.el8_5 @rhel-8-for-x86_64-appstream-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Update a specific package. For example:
sudo yum update java-1.8.0-openjdk
$ sudo yum update java-1.8.0-openjdkCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the update worked by checking the current Red Hat build of OpenJDK versions:
java -version
$ java -version openjdk version "1.8.0_322" OpenJDK Runtime Environment (build 1.8.0_322-b06) OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf the output from the previous command shows that you have a different major version of Red Hat build of OpenJDK checked out on your system, you can enter the following command in your CLI to switch your system to use Red Hat build of OpenJDK 8:
sudo update-alternatives --config 'java'
$ sudo update-alternatives --config 'java'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.2. Updating Red Hat build of OpenJDK 8 on RHEL by using an archive Copiar enlaceEnlace copiado en el portapapeles!
You can update Red Hat build of OpenJDK using the archive. This is useful if the Red Hat build of OpenJDK administrator does not have root privileges.
Prerequisites
-
Know the generic path pointing to your JDK or JRE installation. For example,
~/jdks/java-8
Procedure
Remove the existing symbolic link of the generic path to your JDK or JRE.
For example:
unlink ~/jdks/java-8
$ unlink ~/jdks/java-8Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Install the latest version of the JDK or JRE in your installation location.
Revised on 2024-05-10 09:08:29 UTC