title: Setting the environment for ProcessBuilder
body: <p>I have a strange problem setting the Linux environment from Java (1.6); specifically the "PATH" variable.</p>
  
  <p>In a nutshell, I have a pipeline for running native processes, which uses <code>java.lang.ProcessBuilder</code>. The user can optionally set the environment variables via a <code>HashMap</code> named <code>environment</code>:</p>
  
  <pre><code>ProcessBuilder pb = new ProcessBuilder(args);
  Map&lt;String, String&gt; env = pb.environment();
  if (environment != null)
     env.putAll(environment);
  Process process = pb.start();
  </code></pre>
  
  <p>The <code>env</code> variable gets set properly, if I dump it to the console, with a correct value for the PATH variable. However, running the process results in a thrown <code>Exception</code>:</p>
  
  <p><code>java.io.IOException: error=2, No such file or directory</code></p>
  
  <p>The same process runs fine with identical environment variables in the terminal shell. To test this, I ran Eclipse AFTER setting the environment in the terminal. In this case the <code>ProcessBuilder</code> process runs correctly. </p>
  
  <p>So what must be happening is that the <code>ProcessBuilder</code> is not using the environment I set for it, but the current System environment instead.</p>
  
  <p>I can't find any satisfactory answers to this problem online. Perhaps this is an OS-specific issue? Or something else I'm missing?</p>