Easy Steps To Set up OpenJDK 19 on AlmaLinux 8 – OrcaCore
This guide provides a comprehensive walkthrough on how to Set up OpenJDK 19 on AlmaLinux 8. OpenJDK 19 represents a production-ready, open-source implementation of the Java Development Kit (JDK) version 19, officially released on September 20th, 2022. Adhering to Oracle’s established 6-month release schedule, JDK 19 introduces incremental improvements and new features, primarily in the form of incubator and preview functionalities, without major breaking changes. Follow these straightforward steps, adapted from the Orcacore website, to successfully install and configure OpenJDK 19 on your AlmaLinux 8 system.
Before proceeding with the OpenJDK 19 AlmaLinux 8 installation, ensure you are logged into your server as a non-root user with sudo
privileges. If needed, refer to our guide on Initial Server Setup with AlmaLinux 8 for instructions on creating such a user.
1. Install OpenJDK 19 AlmaLinux 8
The following steps will guide you through the process of downloading, installing, and configuring OpenJDK 19.
First, update the local package index to ensure you have the latest information about available packages:
sudo dnf update -y
Next, install essential utilities required for the installation process:
sudo dnf install curl wget tar -y
Download OpenJDK 19
Navigate to the JDK Downloads page to locate the download link for the latest OpenJDK 19 archive. Use the wget
command to download the archive directly to your server:
sudo wget https://download.java.net/java/GA/jdk19.0.1/afdd2e245b014143b62ccb916125e3ce/10/GPL/openjdk-19.0.1_linux-x64_bin.tar.gz
Once the download is complete, extract the contents of the archive:
sudo tar xvf openjdk-19.0.1_linux-x64_bin.tar.gz
Move the extracted directory to the /opt
directory, a conventional location for manually installed software:
sudo mv jdk-19.0.1 /opt/
Configure Java Environment Path
Now, configure the Java environment variables so that the system can locate the Java installation. Create a new script file in /etc/profile.d/
to set the JAVA_HOME
and PATH
variables:
sudo tee /etc/profile.d/jdk19.sh <<EOF
export JAVA_HOME=/opt/jdk-19.0.1
export PATH=$PATH:$JAVA_HOME/bin
EOF
Source the profile script to apply the changes to your current shell session:
source /etc/profile.d/jdk19.sh
Verify that the JAVA_HOME
variable is correctly set:
echo $JAVA_HOME
**Output**
/opt/jdk-19.0.1
Finally, confirm that Java 19 is correctly installed by checking its version:
java -version

2. Install Java SE Development Kit 19 on AlmaLinux 8
Alternatively, you can install the official Java SE Development Kit 19 from Oracle.
Download the RPM package for CentOS / RHEL / Fedora systems from the Java SE Downloads page:
sudo wget https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.rpm
Install the RPM package using the rpm
command:
sudo rpm -Uvh jdk-19_linux-x64_bin.rpm
**Output**
warning: jdk-19_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:jdk-19-2000:19.0.2-7 ################################# [100%]
Confirm the Java installation on AlmaLinux 8:
java -version

Configure the Java environment variables. Note that the installation path is different when using the RPM package:
cat <<EOF | sudo tee /etc/profile.d/jdk.sh
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
EOF
To use Java Home, source the file by using the following command:
source /etc/profile.d/jdk.sh
3. Test OpenJDK 19 AlmaLinux 8
To verify that Java 19 is functioning correctly, create a simple "Hello, World" program.
Create a file named HelloWorld.java
using a text editor like vi
:
vi HelloWorld.java
Add the following Java code to the file:
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
Save and close the file.
Compile the Java code:
javac HelloWorld.java
Run the compiled Java program:
java HelloWorld
**Output**
Hello, World
That’s it! You have successfully installed and tested OpenJDK 19 on AlmaLinux 8.
Conclusion
This guide detailed the steps necessary to Set up OpenJDK 19 on AlmaLinux 8. You learned how to download and install either OpenJDK 19 or the Java SE Development Kit 19, configure the Java environment, and verify the installation with a simple test program. This ensures that the setup for OpenJDK 19 on AlmaLinux 8 is done correctly.
Alternative Solutions for Installing OpenJDK 19 on AlmaLinux 8
While the previous methods are effective, here are two alternative approaches to installing OpenJDK 19 on AlmaLinux 8, offering different levels of automation and management.
1. Using SDKMAN! (Software Development Kit Manager)
SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits (SDKs) on a Unix-based system. It simplifies the installation, switching, and management of different Java versions, making it a convenient option for developers who work with multiple JDKs.
-
Installation of SDKMAN!:
First, install SDKMAN! using the following commands:
curl -s "https://get.sdkman.io" | bash source "$HOME/.sdkman/bin/sdkman-init.sh" sdk version
-
Installing OpenJDK 19 using SDKMAN!:
Once SDKMAN! is installed, you can easily install OpenJDK 19:
sdk install java 19.0.1-open
This command downloads and installs OpenJDK 19. SDKMAN! handles the download, extraction, and configuration of the environment variables.
-
Setting OpenJDK 19 as Default:
To set OpenJDK 19 as the default Java version, use:
sdk default java 19.0.1-open
-
Verification:
Verify the installation by checking the Java version:
java -version
SDKMAN! provides a cleaner and more managed way to handle different JDK versions, especially useful for developers who need to switch between them frequently.
2. Using a Container (Docker)
Containers provide a lightweight and isolated environment for running applications, including Java applications. Using Docker, you can create a container with OpenJDK 19 pre-installed, ensuring consistency across different environments.
-
Prerequisites:
Ensure that Docker is installed on your AlmaLinux 8 system. If not, install it using:
sudo dnf install docker -y sudo systemctl start docker sudo systemctl enable docker
-
Creating a Dockerfile:
Create a
Dockerfile
with the following content to build a Docker image with OpenJDK 19:FROM almalinux:8 RUN dnf update -y && dnf install -y wget tar RUN wget https://download.java.net/java/GA/jdk19.0.1/afdd2e245b014143b62ccb916125e3ce/10/GPL/openjdk-19.0.1_linux-x64_bin.tar.gz && tar xvf openjdk-19.0.1_linux-x64_bin.tar.gz && mv jdk-19.0.1 /opt/ ENV JAVA_HOME=/opt/jdk-19.0.1 ENV PATH=$PATH:$JAVA_HOME/bin CMD ["java", "-version"]
This Dockerfile uses AlmaLinux 8 as the base image, downloads and installs OpenJDK 19, and sets the necessary environment variables.
-
Building the Docker Image:
Build the Docker image using the following command:
docker build -t openjdk19-almalinux .
-
Running the Docker Container:
Run the Docker container:
docker run openjdk19-almalinux
This command starts a container with OpenJDK 19 installed, and it will output the Java version, confirming the successful installation.
Using Docker offers a highly reproducible and isolated environment for running Java applications, minimizing compatibility issues across different systems.