java_home(1) | General Commands Manual | java_home(1) |
java_home - return a value for $JAVA_HOME
/usr/libexec/java_home [options]
The java_home command returns a path suitable for setting the JAVA_HOME environment variable. It determines this path from the user's preferred JVM based on configured environment variables. Additional constraints may be provided to filter the list of JVMs available. By default, if no constraints match the available list of JVMs, the default order is used. The path is printed to standard output.
/usr/libexec/java_home helps users set a $JAVA_HOME in their login rc files, or provides a way for command-line Java tools to use the most appropriate JVM which can satisfy a minimum version or architecture requirement. The --exec argument can invoke tools in the selected $JAVA_HOME/bin directory, which is useful for starting Java command-line tools from launchd plists without hardcoding the full path to the Java command-line tool.
July 15, 2020 |