The command line used to start an application
is not always readily accessible in many environments. This is especially
true with applications that use embedded Java VMs or ones where the
startup is deeply nested in scripts. In these environments, the JAVA_TOOL_OPTIONS environment variable may be useful to add
options to the command line when the application is run. This environment
variable is primarily intended to support the initialization of tools,
specifically the launching of native or Java agents using the -agentlib or -javaagent options.
The JAVA_TOOL_OPTIONS environment
variable is processed at the time of the invocation of the Java VM.
When this environment variable is set, the JNI_Create_JavaVM() function prepends the value of the environment variable to the options
supplied in its JavaVMInitArgs argument. For
security reasons this option is disabled in setuid processes; that
is, processes where the effective user or group ID differs from the
real user or group ID.
In the following example, the environment variable
is set to launch the hprof profiler when the application
is started:
$ export JAVA_TOOL_OPTIONS=”-agentlib:hprof” |
Although this environment variable is intended
to support the initialization of tools, it is also useful for augmenting
the command line with options for diagnostics purposes. For example,
you could use it to add the -XX:OnError option to the command line when it would be helpful for a script
or command to be executed when a fatal error occurred.
Because this environment variable is processed
when JNI_CreateJavaVM() is called, it cannot
be used to augment the Java launcher options. Some examples of these
launcher options are the following VM selection options:
To pass arguments to the Java launcher, set the JAVA_LAUNCHER_OPTIONS environment variable to a string containing the desired
arguments.
This environment variable is fully described in
the JVMTI specification at:
http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#tooloptions