Difference between _JAVA_OPTIONS, JAVA_TOOL_OPTIONS and JAVA_OPTS

You have pretty much nailed it except that these options are picked up even if you start JVM in-process via a library call.

The fact that _JAVA_OPTIONS is not documented suggests that it is not recommended to use this variable, and I've actually seen people abuse it by setting it in their ~/.bashrc. However, if you want to get to the bottom of this problem, you can check the source of Oracle HotSpot VM (e.g. in OpenJDK7).

You should also remember that there is no guarantee other VMs have or will continue to have support for undocumented variables.

UPDATE 2015-08-04: To save five minutes for folks coming from search engines, _JAVA_OPTIONS trumps command-line arguments, which in turn trump JAVA_TOOL_OPTIONS.


There is one more difference: _JAVA_OPTIONS is Oracle specific. IBM JVM is using IBM_JAVA_OPTIONS instead. This was probably done to be able to define machine-specific options without collisions. JAVA_TOOL_OPTIONS is recognized by all VMs.


JAVA_OPTS have no special handling in JVM at all.

And according to https://bugs.openjdk.java.net/browse/JDK-4971166 the JAVA_TOOL_OPTIONS is included in standard JVMTI specification, does better handling of quoted spaces and should be always preferred instead of undocumented Hotspot-specific _JAVA_OPTIONS.

Also beware that using these prints additional message to stdout that can't be suppressed.


As @ryenus noted, since JDK 9+, there's JDK_JAVA_OPTIONS as the preferred replacement, see What is the difference between JDK_JAVA_OPTIONS and JAVA_TOOL_OPTIONS when using Java 11?