Set default value for java property (system wide)Tag(s): Environment


If you find yourself using the same options over and over before laucing a java process, you can set up a special environment variable to contain your default options and the JVM will pick up the the values.

If the Java process is launch via java.exe then the environment variable is called _JAVA_OPTIONS (see JAVA_TOOL_OPTIONS below for a better option),

e.g. In Windows:

set _JAVA_OPTIONS=-Xms64m -Xmx128m -Dawt.useSystemAAFontSettings=lcd
In Linux:
export _JAVA_OPTIONS='-Xms64m -Xmx128m -Dawt.useSystemAAFontSettings=lcd'
ref : https://docs.oracle.com/javase/8/docs/technotes/guides/2d/flags.html

If the Java process is launch via javaw.exe (Applet) then the environment variable is called _JPI_VM_OPTIONS.

For example :

_JPI_VM_OPTIONS = -Dsome.property=true

For a Java Web Start process (javaws.exe), the environment variable is called JAVAWS_VM_ARGS.

For example :

JAVAWS_VM_ARGS = -Dsome.property=true
ref : http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/plugin.html#gcexdd
But .. The preferred way is to use an environment called JAVA_TOOL_OPTIONS.

_JAVA_OPTIONS environment variable was ok but was not documented or supported. Since it is not standardized, other vendors have their own names e.g. IBM_JAVA_OPTIONS. Leading underscore names are private by convention so it's not a good to standardize the usage of _JAVA_OPTIONS. That's why JAVA_TOOL_OPTIONS should be the preferred choice.

ref : https://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#tooloptions and
https://stackoverflow.com/questions/28327620/difference-between-java-options-java-tool-options-and-java-opts


blog comments powered by Disqus