Share on Social Media

In this configuration guide, you will learn how to install Java 19 on Linux 9. #centlinux #linux #java

What is Java?:

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture.

The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection and runtime code modification) that are typically not available in traditional compiled languages. As of 2019, Java was one of the most popular programming languages in use according to GitHub, particularly for client–server web applications, with a reported 9 million developers. (Source: Wikipedia)

Java was originally developed by James Gosling at Sun Microsystems. It was released in May 1995 as a core component of Sun Microsystems’ Java platform. The original and reference implementation Java compilers, virtual machines, and class libraries were originally released by Sun under proprietary licenses. As of May 2007, in compliance with the specifications of the Java Community Process, Sun had relicensed most of its Java technologies under the GPL-2.0-only license. Oracle offers its own HotSpot Java Virtual Machine, however the official reference implementation is the OpenJDK JVM which is free open-source software and used by most developers and is the default JVM for almost all Linux distributions.

As of September 2022, Java 19 is the latest version, while Java 17, 11 and 8 are the current long-term support (LTS) versions.

Video to install Java 19 on Linux:

YouTube player

Environment Specification:

We are using a minimal Rocky Linux 9 virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – Rocky Linux release 9.0 (Blue Onyx)
  • Hostname – java-01.centlinux-com.preview-domain.com
  • IP Address – 192.168.116.130/24

Update Linux Operating System:

By following the best practice, update your Linux operating system before installing Java 19 software.

Login as root user on your Linux server by using a ssh client.

Refresh your yum cache as follows.

# dnf makecache
Rocky Linux 9 - BaseOS                          786  B/s | 3.6 kB     00:04
Rocky Linux 9 - AppStream                       1.6 kB/s | 3.6 kB     00:02
Rocky Linux 9 - Extras                          334  B/s | 2.9 kB     00:08
Metadata cache created.

Update software packages in your Linux operating system.

# dnf update -y

If the above command update your Linux Kernel then, you should reboot your operating system with new Kernel before installing Java 19 software.

# reboot

Check the Linux operating system and Kernel versions as follows.

# cat /etc/rocky-release
Rocky Linux release 9.0 (Blue Onyx)

# uname -r
5.14.0-70.26.1.el9_0.x86_64

Install Java 19 on Linux:

Java 19 software is available to download at Oracle website.

01-java-download-page

Copy the URL according to your preferred platform and then you can use wget command to download the Java 19 software directly from Linux commandline.

But first, use following command to install wget utility, if it isn’t already installed on your Linux machine.

# dnf install -y wget

Now, by using following commands, download Java 19 RPM into /tmp directory.

# cd /tmp
# wget https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.rpm
--2022-10-26 11:34:05--  https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.rpm
Resolving download.oracle.com (download.oracle.com)... 104.91.72.85
Connecting to download.oracle.com (download.oracle.com)|104.91.72.85|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 169483428 (162M) [application/x-redhat-package-manager]
Saving to: ‘jdk-19_linux-x64_bin.rpm’

jdk-19_linux-x64_bi 100%[===================>] 161.63M   956KB/s    in 2m 20s

2022-10-26 11:36:27 (1.16 MB/s) - ‘jdk-19_linux-x64_bin.rpm’ saved [169483428/169483428]

After successful download, you can invoke dnf command to install Java 19 on Rocky Linux 9.

# dnf install -y jdk-19_linux-x64_bin.rpm
Last metadata expiration check: 0:18:02 ago on Wed 26 Oct 2022 11:27:06 AM CDT.
Dependencies resolved.
================================================================================
 Package       Architecture  Version                  Repository           Size
================================================================================
Installing:
 jdk-19        x86_64        2000:19.0.1-10           @commandline        162 M

Transaction Summary
================================================================================
Install  1 Package

Total size: 162 M
Installed size: 318 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : jdk-19-2000:19.0.1-10.x86_64                           1/1
  Running scriptlet: jdk-19-2000:19.0.1-10.x86_64                           1/1
  Verifying        : jdk-19-2000:19.0.1-10.x86_64                           1/1

Installed:
  jdk-19-2000:19.0.1-10.x86_64

Complete!

To verify Java 19 installation, execute java command to check the version of active Java software. (Note: You can run multiple versions of Java on a Single Linux operating system with the help of alternatives command.)

# java --version
java 19.0.1 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

Java 19 software has been successfully installed. Additionally you can set the following Java environment variables.

# cat << EOF > /etc/profile.d/java.sh
> export JAVA_HOME=/usr/lib/jvm/jdk-19-oracle-x64
> export PATH=$PATH:$JAVA_HOME/bin
> EOF

Conclusion:

In this configuration guide, you have learned how to install Java 19 on Linux 9.

Leave a Reply

Your email address will not be published. Required fields are marked *