Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Information about _JAVA_OPTIONS

Tags:

java

Can anyone explain what does Java do when _JAVA_OPTIONS Environment variable defined & when application launched on the windows machine?

like image 793
Madan Avatar asked Jul 22 '13 06:07

Madan


People also ask

What should be the value of _JAVA_OPTIONS?

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.

What is picked up _JAVA_OPTIONS?

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.

What is the use of JAVA_TOOL_OPTIONS?

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.


Video Answer


2 Answers

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

like image 139
Demi Ben-Ari Avatar answered Sep 24 '22 19:09

Demi Ben-Ari


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?

like image 39
Vadzim Avatar answered Sep 25 '22 19:09

Vadzim