title: Is it possible to set an environment variable at runtime from Java?
body: <p>Is it possible to set an environment variable at runtime from a Java
  application?
  In Java 1.5 java.lang.System class there is the getenv() method, I would
  only need a setenv() method...</p>
  
  <p>Is it possible to modify the environment variables in the java process itself; not in the child process.</p>
  
  <p>Is it possible to achieve it through JNI? And how would that work?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT:
  Ok let me put it this way - Can we do the following with Java. Please answer.</p>
  
  <ol>
  <li>Can we modify the environment of the current process?</li>
  <li>Can we modify the environment of the parent process?</li>
  <li>Can we modify the environment of the child process?</li>
  </ol>
  
  <p>Hemal Pandya has answered that "You can modify the environment of current and child processes but not of the parent process that spawned this process." Do you agree with this ?</p>