'\" t .\" @(#)java_home.1 .\" Copyright 2008-2020 Apple, Inc. All rights reserved. .\" .TH java_home 1 "July 15, 2020" .SH NAME java_home \- return a value for $JAVA_HOME .SH SYNOPSIS \fB/usr/libexec/java_home\fR [\fIoptions\fR] .SH DESCRIPTION The \fBjava_home\fR 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. .SH OPTIONS .TP \fB-v\fR or \fB--version version\fR Filters the returned JVMs by version (as if JAVA_VERSION had been set in the environment). Example versions: "11.0", or "14.0.2". .TP \fB-a\fR or \fB--arch architecture\fR Filters the returned JVMs by the architecture they support (as if JAVA_ARCH had been set in the environment). Example architectures: "x86_64", or "arm64". .TP \fB-F\fR or \fB--failfast\fR Immediately fails when filters return no JVMs; does not print out the path to the default $JAVA_HOME. .TP \fB--exec command ...\fR Executes the command at $JAVA_HOME/bin/ and passes the remaining arguments. Any arguments to select which $JAVA_HOME to use must precede the --exec option. .TP \fB-X\fR or \fB--xml\fR Prints a list of all matching JVMs and associated properties as an XML plist to stdout. .TP \fB-V\fR or \fB--verbose\fR Prints a list of all matching JVMs and architectures to stderr. .TP \fB-h\fR or \fB--help\fR Brief usage information. .SH USAGE \fB/usr/libexec/java_home\fR 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. .TP Usage for bash-style shells: $ export JAVA_HOME=`/usr/libexec/java_home` .TP Usage for csh-style shells: % setenv JAVA_HOME `/usr/libexec/java_home`