title: IOException when starting a process
body: <p>I am trying to run some Mercurial commands from a java program. I build my <code>Process</code> using a <code>ProcessBuilder</code> like this:</p>
  
  <pre><code>final ProcessBuilder procBuilder = new ProcessBuilder("hg", "log");
  
  procBuilder.directory(new File("/Users/feuerball/workspace/www"));
  
  final Process proc = procBuilder.start();
  </code></pre>
  
  <p>The folder <code>www</code> contains a Mercurial repository, <code>hg</code> is installed and in the systems <code>PATH</code>. But my program throws an exception when I start the process. This is the stacktrace:</p>
  
  <pre><code>Exception in thread "main" java.io.IOException: Cannot run program "hg" (in directory "/Users/feuerball/workspace/www"): error=2, No such file or directory
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
      at de.feuerball.tests.Test.main(Test.java:16)
  Caused by: java.io.IOException: error=2, No such file or directory
      at java.lang.UNIXProcess.forkAndExec(Native Method)
      at java.lang.UNIXProcess.&lt;init&gt;(UNIXProcess.java:185)
      at java.lang.ProcessImpl.start(ProcessImpl.java:134)
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
      ... 1 more
  </code></pre>
  
  <p>Why do I get this error?</p>
  
  <p><strong>Update</strong></p>
  
  <p>To show that the directory does exist, I have changed the code a little bit:</p>
  
  <pre><code>final File repo = new File("/Users/feuerball/workspace/www");
  
  System.out.println("Directory? " + repo.isDirectory());
  System.out.println("Readable? " + repo.canRead());
  System.out.println("Writable? " + repo.canWrite());
  
  final ProcessBuilder procBuilder = new ProcessBuilder("hg", "log");
  procBuilder.directory(repo);
  
  final Process proc = procBuilder.start();
  </code></pre>
  
  <p>Now here is the proof:</p>
  
  <pre><code>Directory? true
  Readable? true
  Writable? true
  Exception in thread "main" java.io.IOException: Cannot run program "hg" (in directory "/Users/feuerball/workspace/www"): error=2, No such file or directory
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
      at de.brushmate.tests.Test.main(Test.java:22)
  Caused by: java.io.IOException: error=2, No such file or directory
      at java.lang.UNIXProcess.forkAndExec(Native Method)
      at java.lang.UNIXProcess.&lt;init&gt;(UNIXProcess.java:185)
      at java.lang.ProcessImpl.start(ProcessImpl.java:134)
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
      ... 1 more
  </code></pre>