8

Install Temurin OpenJDK 17 on CentOS 7|RHEL 7|Oracle Linux 7

 2 years ago
source link: https://computingforgeeks.com/install-temurin-openjdk-on-centos-rhel-oracle-linux/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Install Temurin OpenJDK 17 on CentOS 7|RHEL 7|Oracle Linux 7

Java is one of the highly used programming languages in the world. AdoptOpenJDK, also known as Eclipse Temurin is an open-source Java founded in 2017 following a lengthy discussion over the lack of an open-source and test system for OpenJDK. The Eclipse Adoptium group took this task with the main objective of producing a high-quality, TCK-certified technology and runtimes to be used across the Java ecosystem. Ever since its production, AdoptOpenJDK has grown immensely and is now the leading provider of OpenJDK-based binaries which can be used on desktops, modern cloud platforms, traditional servers, enterprises embedded systems, or even mainframes. This success has been achieved through multiple projects as well as a close partnership with external projects i.e OpenJDK to provide the required Java SE runtime implementation.

The AdoptOpenJDK can be installed on various platforms such as Windows,macOS, Linux, and many others. This guide takes an in-depth illustration of how to install Temurin OpenJDK 17 on CentOS 7| RHEL 7 | Oracle Linux 7

Getting Started.

Update your system packages to the latest stable versions.

sudo yum update -y

Install the required package and reboot the system for the changes made to apply.

sudo yum -y install wget curl

1 – Download the Temurin OpenJDK 17 Binary

To download the Temurin OpenJDK 17 binary file, visit the Adoptium downloads page. You can as well choose to pull the binary using Wget as shown.

wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.2_8.tar.gz

Once the download is successful, extract the archive.

tar -xvf OpenJDK17U-jdk_x64_linux_hotspot_17.*.tar.gz
rm -f OpenJDK17U-jdk_x64_linux_hotspot_17.*.tar.gz

2 – Install Temurin OpenJDK 17 on CentOS 7| RHEL 7 | Oracle Linux 7

To install Temurin OpenJDK 17, we will simply move the extracted file above to the /opt/ directory.

sudo mv jdk-17.* /opt/jdk-17

Set the JAVA_HOME environment variables as below.

$ vi ~/.bashrc
export JAVA_HOME=/opt/jdk-17
export PATH=$PATH:$JAVA_HOME/bin 

Souce the profile.

source ~/.bashrc

Verify the set PATH.

$ echo $JAVA_HOME
/opt/jdk-17

That is it, you have installed Temurin OpenJDK 17 on CentOS 7| RHEL 7 | Oracle Linux 7. Verify your installation using the command below.

$ java --version
openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)
OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

Set a Persistent JAVA_HOME Environment Variable.

Setting the JAVA_HOME Environment Variable using the above method is not persistent and is lost on system reboot. However, you can make this persistent by adding the PATH to /etc/profile

$ sudo vi /etc/profile
export JAVA_HOME=/opt/jdk-17
export PATH=$PATH:$JAVA_HOME/bin 

Apply the made changes by either logging out then logging in again or sourcing the profile.

source /etc/profile

Verify the set PATH.

$ echo $JAVA_HOME
/opt/jdk-17

3 – Set Default Java Version On CentOS 7| RHEL 7 | Oracle Linux 7

With multiple Java versions installed on your system, you need to set a default Java version to be used when running Java applications.

First, add the Temurin OpenJDK 17 to the /usr/bin/java path.

sudo alternatives --install /usr/bin/java java /opt/jdk-17/bin/java 1

List the available Java installations.

sudo alternatives --config java

Sample output:

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.14.0.9-1.el7_9.x86_64/bin/java)
   2           /opt/jdk-17/bin/java

Enter to keep the current selection[+], or type selection number: 2

We have set the default java to Temurin OpenJDK 17. Verify this as below.

$ java -version
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)
OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

4 – Test Temurin OpenJDK 17

Once installed, we need to verify if the Java installation is working correctly. We will create a sample file as below.

cat > HelloWorld.java <<EOF
public class helloworld {
  public static void main(String[] args) {
    System.out.println("Hello Java World from Kenya! Temurin OpenJDK is amazing!");
  }
}
EOF

This is a sample HelloWorld application. Compile it as below.

java HelloWorld.java

Execution output:

$ java HelloWorld.java
Hello Java World from Kenya! Temurin OpenJDK is amazing!

That is it!

I hope this guide on how to install Temurin OpenJDK 17 on CentOS 7| RHEL 7 | Oracle Linux 7 was impactful.

See more on this page:


Recommend

  • 8
    • computingforgeeks.com 3 years ago
    • Cache

    How To Install Java 8 on CentOS 8 / RHEL 8 Linux

    How To Install Java 8 on CentOS 8How can I install Java 8 on CentOS 8 / RHEL 8?. On Red Hat Enterprise Linux (RHEL) 8, two major versions of Java are available – Java 11 and Java 8. Our last article addressed the installation of

  • 10
    • computingforgeeks.com 3 years ago
    • Cache

    Install MySQL 5.7 on CentOS 8 / RHEL 8 Linux

    Install MySQL 5.7 on CentOS 8Search ComputingForGeeksAre you looking for a guide to help you install MySQL 5...

  • 8
    • computingforgeeks.com 2 years ago
    • Cache

    How To Install Ifconfig on RHEL 8 / CentOS 8 Linux

    How To Install Ifconfig on RHEL 8Do you get 'Ifconfig' Command Not Found in your RHEL 8 / CentOS 8 minimal server installation?. The minimal installation of RHEL 8 / CentOS 8 doesn’t come with the ifconfig comman...

  • 16

    Install Java 11 (OpenJDK 11) on RHEL 8This article will help you to install Oracle Java 11 on RHEL 8 / CentOS 8 / Rocky Linux 8. Java 11 is a long-term support (LTS) release which was made available to the General public on 25 September 2018...

  • 3

    Rocky Linux 8 vs CentOS Stream 8 vs RHEL 8 vs Oracle Linux 8The future of Linux has lived up to the expectations that most people have when they begin a project, a relationship, career or anything that will be long-term. Linux has had a stell...

  • 10

    Install JBoss EAP 7.x on CentOS 8|RHEL 8|Rocky Linux 8This guide aims to demonstrate how to install JBoss EAP 7.x on CentOS 8|RHEL 8|Rocky Linux 8. But before we dive into the nub of this matter, we will elucidate and get to know what JBoss E...

  • 3
    • computingforgeeks.com 2 years ago
    • Cache

    How To Install Jira on CentOS 8 / RHEL 8 Linux

    JIRA is a project management tool developed by Atlassian. It is also used for issue tracking and bug tracking related to your software development and other Projects. This guide will walk you through the installation Jira on CentOS 8 / RHEL 8...

  • 28
    • computingforgeeks.com 2 years ago
    • Cache

    Install GLPI on CentOS 8|RHEL 8|Rocky Linux 8

    Install GLPI on CentOS 8|RHEL 8|Rocky Linux 8How do I Install GLPI on CentOS 8|RHEL 8|Rocky Linux 8 Linux system?. GLPI is a free and open source IT service management (ITSM) tool for planning and managing Assets in IT operations. With GLPI y...

  • 13
    • computingforgeeks.com 2 years ago
    • Cache

    How To Install KVM on RHEL 8 / CentOS 8 Linux

    How To Install KVM on RHEL 8Search ComputingForGeeksHow to install KVM on RHEL 8 / CentOS 8?. This guide wil...

  • 5

    Install Node.js 18 on CentOS 8|RHEL 8|Rocky Linux 8We all know JavaScript as a language to write once and run anywhere. Node.js is a popular programming language mainly because it uses the JavaScript as the main application to create new appl...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK