How to add an environment variable in Java?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java">How do I set environment variables from Java?</a>  </p>
</blockquote>



<p>I'm working on Java. I have to add an environment variable in java code programmatic such that it will be available when i get list using process builder as follows:</p>

<pre><code>import java.util.Map;
import java.util.Set;

class helloworld  {
    public static void main(String[] args) {

        ProcessBuilder pb = new ProcessBuilder("export MY_ENV_VAR=1");

        Map&lt;String, String&gt; envMap = pb.environment();

        Set&lt;String&gt; keys = envMap.keySet();
        for(String key:keys){
            System.out.println(key+" ==&gt; "+envMap.get(key));
        }

    }
}
</code></pre>

<p>But with above trial i cant get environment variable properly.
so How to set the environment variable ?</p>
