I am trying to run a JVM service and it needs JAVA_HOME set.
java is on my PATH, but it's not clear what JAVA_HOME should be set to:
which java
/usr/bin/java
I am trying to run a JVM service and it needs JAVA_HOME set.
java is on my PATH, but it's not clear what JAVA_HOME should be set to:
which java
/usr/bin/java
Copyright © 2021 Jogjafile Inc.
While
alternativesmay remain popular on *nix systems, I mostly use jenv and occasionally sdkman; they all introduce a level of indirection, if/usr/bin/javawas not obscure enough.If you are happy with the version of
javaon yourPATH(java -version), you can queryjavadirectly forjava.home:This is not available in Java 6:
It is available since Java 7:
For ease of use, create an alias:
Alternatives:
jrunscriptorjshellSome distributions provide
jrunscriptorjshell; these can be used to run Java code as script:or
Note this approach and these tools are old and should be considered deprecated.
Java as a Source Interpreter
Since Java 11 you can execute Java source code as a script directly on the
javabinary: