Hello,
here is some clarification of the relationship between JAVA_HOME and the
PATH.
JAVA_HOME points to the base directory of a Java JRE or JDK
(=development) directory. Under $JAVA_HOME one should find a bin
directory which contains java, javac and other binaries.
In the case you just need the wanted java or javac in the execution path
actually JAVA_HOME is not needed. Simple hello-world like compilations
from command line work ok when java(c) is in path.
Java based tools make typically use of JAVA_HOME and some of them refuse
to start unless JAVA_HOME is set to a valid location. E.g. Maven even
prefers JAVA_HOME over the version of javac that is in the execution path:
$ $ echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk
$ mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555;
2019-04-04T22:00:29+03:00)
Maven home: /opt/maven/apache-maven-3.6.1
Java version: 11.0.16.1, vendor: Red Hat, Inc., runtime:
/usr/lib/jvm/java-11-openjdk-11.0.16.1.1-1.fc36.x86_64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.19.10-200.fc36.x86_64", arch: "amd64",
family: "unix"
but
$ java -version
openjdk version "17.0.4.1" 2022-08-12
OpenJDK Runtime Environment (Red_Hat-17.0.4.1.1-1.fc36) (build 17.0.4.1+1)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.4.1.1-1.fc36) (build 17.0.4.1+1,
mixed mode, sharing)
BR,
Roland