title: CreateProcess error=2, The system cannot find the file specified
body: <p>I am writing a program in java which would execute winrar and unzip a jar file for me placed in <code>h:\myjar.jar</code> into the folder <code>h:\new</code>. My java code goes something like this</p>
  
  <pre><code>import java.io.File;
  import java.io.IOException;
  
  public class MainClass {
  
      public static void main(String[] args) {
  
          Runtime r = Runtime.getRuntime();
          Process p = null;
  
          try {
              File dir = new File("C:/Program Files/WinRAR");
              p = r.exec("winrar x h:\\myjar.jar *.* h:\\new", null, dir);
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>When I execute this, I am getting this error</p>
  
  <pre><code>java.io.IOException: Cannot run program "winrar" (in directory "C:\Program Files\WinRAR"): CreateProcess error=2, The system cannot find the file specified
      at java.lang.ProcessBuilder.start(Unknown Source)
      at java.lang.Runtime.exec(Unknown Source)
      at java.lang.Runtime.exec(Unknown Source)
      at MainClass.main(MainClass.java:16)
  Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
      at java.lang.ProcessImpl.create(Native Method)
      at java.lang.ProcessImpl.&lt;init&gt;(Unknown Source)
      at java.lang.ProcessImpl.start(Unknown Source)
      ... 4 more
  </code></pre>
  
  <p>Can anyone tell me why am I encountering such a problem. What is the change I need to incorporate in code so that it works?</p>