title: java.io.IOException:Cannot run program "sh" (in directory"c:\cygwin\bin\test"):CreateProcess error=2.The system cannot find file specified
body: <p>I am running shell scripts with the help of java and cygwin. When i am running my code in windows xp it works fine. Now i am trying to run same code on windows 7 i am getting above error.</p>
  
  <pre><code>(java.io.IOException)java.io.IOException:
  Cannot run program "sh" (in directory"c:\cygwin\bin\test"):
  CreateProcess error=2.The system cannot find file specified
  </code></pre>
  
  <p>Why this error occurred.I have set my path for cygwin <code>(PATH=.;c:\cygwin\bin)</code> How to avoid this.</p>
  
  <pre><code>ProcessBuilder pb = new ProcessBuilder ();
  pb.directory(new File("C:\\cygwin\\bin\\Test\\"));
  File shellfile = new File("app.sh");//File name with extension
  System.out.println(shellfile.getCanonicalPath());
  </code></pre>
  
  <p>But it is giving the output as <code>E:\NIRAJ\example\app.sh</code> which is in my java  program. even i am setting up pb.directory to the path.</p>
  
  <p>if i check <code>System.out.print(pb.directory());</code> it gives me output <code>C:\cygwin\bin\Test</code></p>