- Download Red Hat build of OpenJDK
- Get the Red Hat build of OpenJDK
- Install Red Hat build of OpenJDK
- Download container images
- Migration Toolkit for Applications
- Use OpenJDK on Red Hat OpenShift
- Run Java applications with OpenJDK
- Run Quarkus apps with Red Hat build of OpenJDK
- Run Spring Boot apps with Red Hat build of OpenJDK
- Run JBoss EAP apps with Red Hat build of OpenJDK
- Deploying your Java applications
- Deploy your source [S2I]
- Containerize Your App
- Deploy Jar file
- Install Red Hat build of OpenJDK runtime
- Red Hat Enterprise Linux (RHEL)
- Using Yum Installer:
- Using Tar.xz File:
- Windows
- Install OpenJDK on Windows:
- macOS
- Install the latest LTS version:
- Install a specific version with Homebrew:
- Uninstall a specific version:
- Alternate Options:
- SDKMAN:
- Chocolatey:
- Other Linux
- Debian/Ubuntu — Install the latest LTS version:
- CentOS/RHEL/Fedora — Install the latest LTS version:
- openSUSE/SLES — Install the latest LTS version:
- Alternate Options:
- SDKMAN:
- Chocolatey:
- All Downloads
- July 2023
- April 2023
- January 2023
- October 2022
- August 2022
- July 2022
- May 2022
- April 2022
- January 2022
- October 2021
- July 2021
- April 2021
- January 2021
- October 2020
- July 2020
- April 2020
- January 2020
- October 2019
- July 2019
- April 2019
- January 2019
- October 2018
- July 2018
- April 2018
- 8u161
- 9.0.4
- 9.0.1
- 8u151
- 8u144
- 9ea181
- 8u141
- 9b163 EA
- 8u131
- 9b154 EA
- 8u121
- 8u111-3
- 8u111
- 8u102
- 8u101
- 8u91
- Products
- Build
- Quicklinks
- Communicate
- RED HAT DEVELOPER
- Red Hat legal and privacy links
- Red Hat legal and privacy links
- How to run the correct Java version after an update
- The reason for the error message
- The importance of JAVA_HOME
- Choosing a JDK
- Updating .bashrc
- Updating the shell
- Install and Upgrade Java Version on CentOs ,Red Hat and Fedora Linux
- Downloading Latest Java Version Linux Binary
- Linux x64 Java Development Kit
- Installation of Latest Java
- Update Java
- Check updated Java Version :
Download Red Hat build of OpenJDK
The Red Hat build of OpenJDK is a free and open source implementation of the Java Platform, Standard Edition (Java SE).
Get the Red Hat build of OpenJDK
Install Red Hat build of OpenJDK
Red Hat build of OpenJDK enables running Java applications in your environment
Download container images
Build your container now. Download secure, certified, and up-to-date container images for the Red Hat build of OpenJDK.
Migration Toolkit for Applications
Simplify the modernization of your legacy applications and reduce risks with the migration toolkit for applications, which is included with a Red Hat OpenShift subscription.
Use OpenJDK on Red Hat OpenShift
Red Hat build of OpenJDK runtimes enables you to run Java applications on OpenShift. You can choose to directly deploy your source using S2I or you can containerize your applications using our certified container images to run your apps on OpenShift
Run Java applications with OpenJDK
Run Quarkus apps with Red Hat build of OpenJDK
Once you have Red Hat build of OpenJDK installed, you can clone and run this locally or use the source to image option on OpenShift to run it on your cluster.
https://github.com/quarkusio/quarkus-super-heroes
Run Spring Boot apps with Red Hat build of OpenJDK
Once you have Red Hat build of OpenJDK installed, you can clone and run this locally or use the source to image option on OpenShift to run it on your cluster.
https://github.com/redhat-mw-demos/hello-world-spring-openjdk
Run JBoss EAP apps with Red Hat build of OpenJDK
Once you have Red Hat build of OpenJDK installed, you can clone and run this locally or use the source to image option on OpenShift to run it on your cluster.
https://github.com/jboss-developer/jboss-eap-quickstarts/tree/7.4.x/helloworld-rs
Deploying your Java applications
Red Hat build of OpenJDK enables you to run any Java applications in any environment. Explore the options below and choose the option that works the best for you.
Deploy your source [S2I]
Developers can simply specify the git repository of the source and OpenShift will automatically build and image deploy it.
Containerize Your App
Once you have Red Hat build of OpenJDK installed, you can clone and run this locally or use the source to image option on OpenShift to run it on your cluster
Deploy Jar file
If your applications can be packages into a jar file, the jar files can be uploaded to OpenShift for deployment
Install Red Hat build of OpenJDK runtime
Red Hat build of OpenJDK is available for RHEL, Windows, and other Linux environments too as a Java Runtime Environment(JRE) and a complete Java Development Kit (JDK)
Red Hat Enterprise Linux (RHEL)
Using Yum Installer:
$ sudo yum install java-17-openjdk $ java -version openjdk version "17.0.2" 2022-01-18 LTS OpenJDK Runtime Environment 21.9 (build 17.0.2+8-LTS) OpenJDK 64-Bit Server VM 21.9 (build 17.0.2+8-LTS, mixed mode, sharing)
Using Tar.xz File:
$ mkdir ~/jdks $ cd ~/jdks $ tar -xf java-17-openjdk-17.0.5.0.8-2.portable.jre.el7.x86_64.tar.xz -C ~/jdks $ ln -s ~/jdks/java-17-openjdk-17.0.5.0.8-2.portable.jdk.el7.x86_64 ~/jdks/java-17 $ export JAVA_HOME=~/jdks/java-17
Windows
Install OpenJDK on Windows:
- Download the installer here.
- Download the package and install it manually:
- Download the file here.
- Extract the contents of an archive to a directory of your choice.
- Set the path:
C:\> setx /m PATH "%PATH%;C:\Progra~1\RedHat\java-17-openjdk-17.0.0.0.35-1\bin"
C:\> setx /m JAVA_HOME "C:\Progra~1\RedHat\java-17-openjdk-17.0.0.0.35-1"
macOS
Red Hat build of OpenJDK is not available for Mac.
However, there’s Temurin, a version of OpenJDK that Red Hat actively contributes to that’s available for Mac.Install the latest LTS version:
brew install –cask temurin
Install a specific version with Homebrew:
brew tap homebrew/cask-version brew install --cask temurin17 brew install --cask temurin11
Uninstall a specific version:
brew uninstall --cask temurin
Alternate Options:
SDKMAN:
Chocolatey:
Other Linux
Red Hat build of OpenJDK is available only on Windows and RHEL.
However, there’s Temurin, a version of OpenJDK that Red Hat actively contribute to that’s available for Debian and RPG Linux.Debian/Ubuntu — Install the latest LTS version:
apt-get install temurin-17-jdk
CentOS/RHEL/Fedora — Install the latest LTS version:
openSUSE/SLES — Install the latest LTS version:
zypper install temurin-17-jdk
Alternate Options:
SDKMAN:
Chocolatey:
All Downloads
July 2023
April 2023
January 2023
October 2022
August 2022
July 2022
May 2022
April 2022
January 2022
October 2021
July 2021
April 2021
January 2021
October 2020
July 2020
April 2020
January 2020
October 2019
July 2019
April 2019
January 2019
October 2018
July 2018
April 2018
8u161
9.0.4
9.0.1
8u151
8u144
9ea181
8u141
9b163 EA
8u131
9b154 EA
8u121
8u111-3
8u111
8u102
8u101
8u91
Products
Build
Quicklinks
Communicate
RED HAT DEVELOPER
We serve the builders. The problem solvers who create careers with code.
Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.
We’ve updated our Privacy Statement effective July 1, 2023
Red Hat legal and privacy links
Red Hat legal and privacy links
How to run the correct Java version after an update
When you try to run a Java program after updating your system’s version of Java, you are likely to receive an error message such as the following:
mvn install The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE
The source of the problem is probably the setting of your JAVA_HOME environment variable. This article shows you how to fix this problem.
The reason for the error message
Java programs need a Java Runtime Environment (JRE) to run. When you program with Java, the JRE is part of the Java Development Kit (JDK). The meanings of these terms follow:
- Java Runtime Environment (JRE): Java source code is compiled and converted to Java bytecode. If you want to run this bytecode on your platform, you need the JRE to load and interpret the bytecode.
- Java Development Kit (JDK): This includes a JRE along with a collection of software development tools and libraries to create Java programs that can run on the platform using the JRE.
The importance of JAVA_HOME
Your shell finds the proper Java environment through an environment variable called JAVA_HOME . It could point to either a JDK or a JRE. As the error message shown earlier indicates, you should point to your JDK if you have a JDK. When non-developers run Java, they don’t need the entire JDK, so they can download a JRE and point JAVA_HOME to that. You can learn more about the Java platform components in the article, What is the Java Runtime Environment.
When you upgrade Java, the system installs a new JDK, and you need to update JAVA_HOME to point to the new location.
Environment variables used in the shell are generally defined in a start-up file. This file is located in your home directory and is called .bashrc if you use the Bash shell that is the default on Linux. Note the initial dot in the name .bashrc : this dot means that the file doesn’t normally turn up when you display the contents of the directory.
The .bashrc file is a script that runs when a user logs in. The file itself contains a series of commands to configure the terminal session.
Check your .bashrc file to see whether it defines JAVA_HOME and what value is assigned to the environment variable. For instance, you can execute this command in the terminal:
The line defining JAVA_HOME in the output is as follows:
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-17.0.4.1.1–1.fc35.x86_64
You have to make sure that JAVA_HOME is set correctly, with version details.
Choosing a JDK
In the terminal on a Linux system, run the following command:
$ sudo alternatives --config java
The output displays the versions of Java currently on the system, as shown in Figure 1. The command also issues a prompt allowing you to choose a version.
The version you choose (3 in the figure) contains, within parentheses, a full pathname that you have to assign to your JAVA_HOME environment variable in your .bashrc file. After entering the number that you want to use, press the Enter key to finish the command.
Updating .bashrc
The next step is to check the value of JAVA_HOME (or add it, if it is not already present) in the .bashrc file. If .bashrc doesn’t match the pathname you choose, you can copy the pathname from the terminal display and paste it into .bashrc as I’ll show shortly.
Figure 2 highlights the JDK path I selected in Figure 1.
Figure 3 highlights the JDK path in the JAVA_HOME setting in my current .bashrc file.
The paths are different, so I need to update the environment variable in the .bashrc file to match the path offered by the system. Specifically, I need to change the JDK version in the path from openjdk-17.0.4.1.1–1.fc35.x86_64 to openjdk-17.0.5.0.8–2.fc35.x86_64 .
When you save your changes, .bashrc looks like Figure 4.
Updating the shell
To reflect the changes in your shell, either close and launch the terminal again or use the following command:
In this way, you can easily update your JAVA_HOME environment variable and continue coding in Java.
Install and Upgrade Java Version on CentOs ,Red Hat and Fedora Linux
When the server OS is installed on the server or system, most of the time java version is not updated or not installed on the operating system, and also sometimes we need to update or upgrade the java version on the server. Earlier in our article, we had to install any version of Java on a freshly installed server. Now we are going to upgrade or update the Java version from the old java version to the latest version. Here you can see also the multiple version of java also installed on the server. Recently Java version 16 also launched.
Below is my java version, I ran the command to check the java version java -version, Nowhere is the output of my command.
[[email protected]]# java --version openjdk 11 2018-09-25 OpenJDK Runtime Environment 18.9 (build 11+28) OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)
Below are the steps to installed or upgrade the java version.
Downloading Latest Java Version Linux Binary
Here was the java launch recently update OpenJDK 16, so we have downloaded it on the server through the below command. You can find the latest version of java on the official site page. Oracle also provides the latest OpenJDK release at jdk.java.net under the GPL License.
Run below command to download and extract the downloaded file .
Linux x64 Java Development Kit
# cd /tmp # wget https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_linux-x64_bin.tar.gz # tar xzf openjdk-16.0.1_linux-x64_bin.tar.gz # mv jdk-16.0.1 /opt
As we have earlier discussed in other articles that –no-cookies and –header options with curl or wget because oracle does not give download unless we have not accepted their license or terms .for accept header and license use the above syntax for download.
Installation of Latest Java
Update Java
Now go to the java extracted folder through the below command and install or switch to java version through alternatives command. This is the best way to install or switch the java version to other. When we run the alternatives –config java , the command output will show different java programs which provide java, We need to choose or select command.Here we have selected /opt/jdk-16.0.1/bin/java .Follow below command to set up.
# cd /opt/jdk-16.0.1 # alternatives --install /usr/bin/java java /opt/jdk-16.0.1/bin/java 2 # alternatives --config java
Now set the jar and javac path .
# alternatives --install /usr/bin/jar jar /opt/jdk-16.0.1/bin/jar 2 # alternatives --install /usr/bin/javac javac /opt/jdk-16.0.1/bin/javac 2 # alternatives --set jar /opt/jdk-16.0.1/bin/jar # alternatives --set javac /opt/jdk-16.0.1/bin/javac
Now set the Environment Variables path of Java,Jre home variable through below commands
# export JAVA_HOME=/opt/jdk-16.0.1/ # export JRE_HOME=/opt/jdk-16.0.1/jre
Check updated Java Version :
[[email protected] jdk-16.0.1]# java --version openjdk 16.0.1 2021-04-20 OpenJDK Runtime Environment (build 16.0.1+9-24) OpenJDK 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)
I am a professional freelance contributor and founder of tech transit. Love to write and lover of education, culture, and community. I have been using it, setting, supporting, and maintaining it since 2009.Linux rocks!