Java System Environment Variable

前端 未结 2 793
悲哀的现实
悲哀的现实 2020-12-17 23:38

Does Java have a default System Environment Variable that will always be read/appended when we set it? CATALINA_OTPS/JAVA_OPTS etc seems only for T

相关标签:
2条回答
  • 2020-12-18 00:13

    There is a special environment variable called _JAVA_OPTIONS, its value will be picked up by the JVM (java.exe).

    In Windows:

    set _JAVA_OPTIONS=-Xms64m -Xmx128m -Dawt.useSystemAAFontSettings=lcd
    

    In Linux:

    export _JAVA_OPTIONS='-Xms64m -Xmx128m -Dawt.useSystemAAFontSettings=lcd'
    

    For Java Web Start it's JAVAWS_VM_ARGS. For javaw.exe (Applet), it's _JPI_VM_OPTIONS.


    edit 20201213

    _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 idea 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

    0 讨论(0)
  • 2020-12-18 00:36

    Java has a standard OS system environment variable that is always set when the JVM is launched:

    • os.name
    • os.arch
    • os.version

    All accessible via 'System.getProperty(propertyName)`

    If you need anything more than this you could always use the Management API.

    0 讨论(0)
提交回复
热议问题