title: Passing environment variables to a JVM, in a platform-independent manner
body: <p>I'm developing a J2EE application that runs in JBoss on a Windows Vista machine, but the application will end up on a Linux machine. Is there a way to pass in the value of an environment variable in a platform independent way?</p>
  
  <p>I think (but I'm not sure) the platform-sensitive way would be:</p>
  
  <pre><code>-Denv_var=%MY_ENV_VAR% (Windows)
  -Denv_var=$MY_ENV_VAR (Linux)
  </code></pre>
  
  <p>and from there I would access the value (in Java) using</p>
  
  <pre><code>System.getProperty("MY_ENV_VAR");
  </code></pre>
  
  <p>— is that correct?</p>
  
  <p>The Javadoc for <code>System.getenv(String name)</code> seem to imply that method is platform-dependent, but I'm not clear on that. Could I just skip passing the variable into the JVM completely, and use <code>getenv()</code> after using setting the value for an environment variable using the OS?</p>