Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7637295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:54:04+00:00 2026-05-31T07:54:04+00:00

Does Java have a default System Environment Variable that will always be read/appended when

  • 0

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 TOMCAT/JBOSS etc.

  1. I do not want to set it through Java system properties (which is passed in via -Dprop1=value1 -Dprop2=value2) as it involves shell/batch script.
  2. It should work across OS, like double click jar file in Windows.
  3. It should work across different JREs (Sun, IBM, OpenJDK etc).
  4. It should not involve extra coding.
  5. It should work in most libraries configuration file, like setting log4j
    level ${LOG_LEVEL}.

Update: Added item # 4 and 5. Remove OS from title to make my question clearer.

Update 2: After looking at Perception’s answer, it seems like my item 2 and 3 can be achieved via System.getenv. How to achieve item 4 and 5?

Here is example of scenario:
Imagine now JAVA_DEFAULT_OPTS is an environment variable that will be read by Java as it has now become the standard. On development desktop machine, I set JAVA_DEFAULT_OPTS=-DLOG_LEVEL=DEBUG -Xmx384m; On production server machine, customers set JAVA_DEFAULT_OPTS=-DLOG_LEVEL=INFO -Xmx1024m. When I/users double click the jar file on Windows, the application will run will different log4j level and max memory heap size.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:54:06+00:00Added an answer on May 31, 2026 at 7:54 am

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am aware that by default Java does not have the so-called eval (what
Does Java have a built-in way to escape arbitrary text so that it can
Does Java have a data type that represents a period of time eg 34
Does Java have (or is there a library available) that allows me to have
I have read everywhere that unsigned Java applets are not allowed to make network
Does Java have buffer overflows? If yes can you give me scenarios?
Does Java have an equivalent to .NET resource (.resx) files for localization? In .NET,
Does java have an equivalent operator or language construct as the verbatim operator(@) in
Does Java have a built-in Antivirus? One of my friends told me there is
Why does Java have transient fields?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.