title: Diff exiting with error code 1
body: <p>I am trying to apply diff on two folders on the files which have same name.</p>
  
  <p>I am checking name of files and then applying diff over them.</p>
  
  <p>I am also calculating CKJM Metrics for them.</p>
  
  <p>On running it is exiting with error code 1. </p>
  
  <p>Kindly help in running CMD operations through java program . </p>
  
  <pre><code>Error : Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  Exited with error code 1
  The common file names are [Inverse Trigono.doc, Limit _ Continuity &amp; Differentia
  bility.doc, Parabola.doc, Permutation and combination.doc, Probability.doc, Quad
  ratic Equation and Expression.doc, Sequence and Series.doc, Solution of triangle
  .doc, Straight Line.doc, TEST PAPER.rar, Vectors.doc]
  </code></pre>
  
  <p>p.s. I have gone through nearly all similar questions asked here but it seems like This is a bit different.</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.File;
  import java.io.InputStreamReader;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  
  public class ListFiles111 {
  
      public static void main(String[] args) {
  
              // Path of Folder 1
          String path1 = "C:\\Users\\hi\\Downloads\\IIT Typing\\IIT Typing"; 
  
              // Path of Folder 2
          String path2 = "C:\\Users\\hi\\Downloads\\IIT Typing\\IIT Typing"; 2
  
          File folder1 = new File(path1);
          File folder2 = new File(path2);
  
          ArrayList&lt;String&gt; commonfiles = new ArrayList&lt;&gt;();
  
              // Array list of files of folder 1 created.
          List&lt;File&gt; filesList1 = Arrays.asList(folder1.listFiles());
  
              // Array list of files of folder 1 created
          List&lt;File&gt; filesList2 = Arrays.asList(folder2.listFiles());
  
  
          for (File f1 : filesList1) 
          {
              if (f1.isFile()) 
              {
                  for (File f2 : filesList2) 
                  {
                      if (f2.isFile() &amp;&amp; f1.getName().equals(f2.getName())) 
                      {
                                        // Adding common name files in new Array list
                          commonfiles.add(f1.getName());                                          
                          try 
                          {
                              Runtime rt = Runtime.getRuntime();
  
                              String[] cmd = new String[5];
                              cmd[0] = "cmd.exe " ;
                              cmd[1] = "/C " ;
                              cmd[2] = "diff ";
                              cmd[3] = f1.getName() + " ";
                              cmd[4] = f2.getName();
  
                              Process pr = rt.exec( cmd );
  
                              BufferedReader input = new BufferedReader(
                                      new InputStreamReader(pr.getInputStream()));
  
                              String line = null;
  
                              while ((line = input.readLine()) != null) 
                              {
                                  System.out.println(line);
                              }
  
                              int exitVal = pr.waitFor();
                              System.out.println("Exited with error code "
                                      + exitVal);
  
                          } 
                          catch (Exception e) 
                          {
                              System.out.println(e.toString());
                              e.printStackTrace();
                          }
  
                          try 
                          {
                              Runtime rt = Runtime.getRuntime();
  
                              String[] cmdd = new String[6];
                              cmdd[0] = "cmd.exe " ;
                              cmdd[1] = "/C " ;
                              cmdd[2] = "java ";
                              cmdd[3] = "-jar ";
                              cmdd[4] = "C:\\Users\\hi\\Desktop\\ckjm-1.9\\build\\ckjm-1.9.jar ";
                      cmdd[5] = "C:\\Users\\hi\\Desktop\\*.class";
  
                              Process pr = rt.exec( cmdd );
  
                              BufferedReader input = new BufferedReader(
                                      new InputStreamReader(pr.getInputStream()));
  
                              String line = null;
  
                              while ((line = input.readLine()) != null) 
                              {
                                  System.out.println(line);
                              }
  
                              int exitVal = pr.waitFor();
                              System.out.println("Exited with error code "
                                      + exitVal);
  
                          } 
                          catch (Exception e) 
                          {
                              System.out.println(e.toString());
                              e.printStackTrace();
                          }
  
                      }
                  }
              }
          }
  
          System.out.println("The common file names are " + commonfiles);
      }
  }
  </code></pre>