Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Nov 6, 2023 10:38:12 AM
Nov 6, 2023 10:38:12 AM
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
# more talend-remote-engine-wrapper.conf [...] set.default.JAVA_HOME=/usr/lib/jvm/java-17-openjdk {...]
# more start_rs.sh [...] MY_JAVA=/usr/lib/jvm/java-17-openjdk