find-default-jvm — set the JAVA_HOME environmnent variable to denote the default JVM
find-default-jvm
{next-prog
}
find-default-jvm is a chain-loading utility that sets the JAVA_HOME
environment variable to denote the root directory for the default JVM, and then chain loads to next-prog
with the execvp(3) function.
If the environment variable is already set, it simply chain loads and does not alter it.
next-prog
may contain its own command line options, which find-default-jvm will ignore.
If the /usr/local/etc/jvms
file exists, it is expected to be a (potentially commented) list of JVM programs, in descending priority order.
The default JVM is the first in the list.
The JAVA_HOME
variable is set to the root of the JVM subtree, which is presumed to be the directory above the directory containing the named JVM program.
If that file does not exist, then if the /usr/lib/jvm
directory exists it is presumed to contain all of the JVM subtree root directories, either directly or as symbolic links.
The JAVA_HOME
variable is set to the one named default-java
if that exists.
Failing either of those, the /usr/local/bin/java
and /usr/bin/java
files are checked in order, and if found the JAVA_HOME
variable is set to the root of the JVM subtree, which is presumed from those filenames as aforementioned.
Finally, as a last resort, the JVM root is presumed to be /
which implies the JVM program at /bin/java
.