Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT

Best practices for running JDK 8, 11, and 17 on Linux

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
TalendSolutionExpert
Contributor II
Contributor II

Best practices for running JDK 8, 11, and 17 on Linux

Last Update:

Nov 6, 2023 10:38:12 AM

Updated By:

TalendSolutionExpert

Created date:

Nov 6, 2023 10:38:12 AM

Overview

This article tells you how to configure your Jobs, JobServer, and a Remote Engine to use JDK 8, 11, and 17 on Linux.

How Linux distributions work with the Java binary

Linux distributions do not add JAVA_HOME/bin in the path. Instead, there is a Java executable in /usr/bin. This binary is a symbolic link to /etc/alternatives/java, which is a symbolic link to /usr/lib/jvm/JDK-version/bin/java. Setting JAVA_HOME is not required to use Java, because it works out of the box.
 

$ java -version
openjdk version "11.0.20" 2023-07-18 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.20.0.8-1) (build 11.0.20+8-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.20.0.8-1) (build 11.0.20+8-LTS, mixed mode, sharing)

$ which java
/usr/bin/java

$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Oct 18 10:47 /usr/bin/java -> /etc/alternatives/java

$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 62 Oct 26 10:58 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-11.0.20.0.8-3.el9.x86_64/bin/java


To change the release to run by default, you must change the symbolic link /etc/alternatives/java by replacing it with the command update-alternatives --config java.

$sudo  update-alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.20.0.8-3.el9.x86_64/bin/java)
   2           java-17-openjdk.x86_64 (/usr/lib/jvm/java-17-openjdk-17.0.9.0.9-2.el9.x86_64/bin/java)

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


This implementation means that all JAR files you run with a Java command will only use the system default Java. This also works for JDK installed with a package manager (APT or YUM).

You can add manually-installed JDK using the following command:

$sudo update-alternatives --install /usr/bin/java java /opt/portable-jdk/bin/java 0

or 

$sudo ln -s /opt/portable-jdk/bin/java /etc/alternatives/java 

 

How Talend software works with Java

Talend Remote Engine

Before installing the Remote Engine, you must update JAVA_HOME to a JDK path. JDK uses this variable to run the Remote Engine and it is stored on the wrapper.conf file. 
 
# more talend-remote-engine-wrapper.conf
[...]
set.default.JAVA_HOME=/usr/lib/jvm/java-17-openjdk
{...]

You can change this value to the new Java path when the Remote Engine is stopped.

JobServer

# more start_rs.sh
[...]
MY_JAVA=/usr/lib/jvm/java-17-openjdk
 

How to use different Java for Jobs, Remote Engines, and JobServers

In summary, when using different Java for Jobs, JobServers, and Remote Engines:

The system default Java code will be the Java that runs the Job. The update-alternatives --config Java command makes you select the JDK to run the Jobs.

The Remote Engine uses the JAVA_HOME variable set just before installation in the configuration file, and JobServer uses the Java in the configuration file.

This means the Jobs use /usr/bin/java and the Remote Engine or JobServer uses JAVA_HOME/bin/java.
Contributors
Version history
Last update:
‎2023-11-06 10:38 AM
Updated by: