Information about _JAVA_OPTIONS
Asked Answered
S

2

57

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

Sequestrate answered 22/7, 2013 at 6:42 Comment(2)
See also Difference between _JAVA_OPTIONS JAVA_TOOL_OPTIONS and JAVA_OPTSStylopodium
I don't know but I found _JAVA_OPTIONS in my registry under HKCU/Environment. I delete that environment key and it really helped (Gradle was choking since I had an option in there pointing to a folder that I no longer had access to)Gaddi
G
60

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

Gunshot answered 19/12, 2013 at 6:6 Comment(3)
It is generally considered good practice to copy the relevant section into the answer, as blogs and other external references end up getting deleted.Cavender
Thanks for the comment, Will do in the future, but the answer was just too long to write in the comment.Gunshot
It is better to use JAVA_TOOL_OPTIONS instead of _JAVA_OPTIONS as per bugs.openjdk.java.net/browse/JDK-4971166Aril
S
29

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?

Stylopodium answered 22/11, 2016 at 8:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.