Can anyone explain what does Java do when _JAVA_OPTIONS
Environment variable defined & when application launched on the windows machine?
You can use _JAVA_OPTIONS to pass options to any JVM process started on your system. When a JVM starts, it parses the value of _JAVA_OPTIONS as if the parameters were at the command line of java. You can see the passed parameters via JVisualVM.
If Using Ubuntu 16.04, Check etc/profile there you may find _JAVA_OPTIONS: -Xmx256M set. That's a file where environment variables are set for the whole. I assume you are facing this message for every java application you run. Although there are other ways to set environment variables.
In these environments the JAVA_TOOL_OPTIONS environment variable can be useful to augment a command line. When this environment variable is set, the JNI_CreateJavaVM function (in the JNI Invocation API) prepends the value of the environment variable to the options supplied in its JavaVMInitArgs argument.
You can use _JAVA_OPTIONS
to pass options to any JVM process started on your system.
For example,
set _JAVA_OPTIONS=-Dsun.java2d.noddraw=true
When a JVM starts, it parses the value of _JAVA_OPTIONS
as if the parameters were at the command line of java. You can see the passed parameters via JVisualVM.
For more information, read the blog post: What I discovered while trying to pass Default JVM Parameters
And according to https://bugs.openjdk.java.net/browse/JDK-4971166 undocumented Hotspot-specific _JAVA_OPTIONS
was superseded by JAVA_TOOL_OPTIONS
that is included in standard JVMTI specification, does better handling of quoted spaces and should be always preferred.
Since JDK 9+ there's also JDK_JAVA_OPTIONS as the preferred replacement, see What is the difference between JDK_JAVA_OPTIONS and JAVA_TOOL_OPTIONS when using Java 11?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With