How to run command line within java using thread async
<p>I am new to java. I am tasked to write java program to run the command lines. I tested the command line under the DOS prompt since i do not have have access to Linux box yet. it worked fine. See the PROGRAM below for full command line syntax. the job will take 6 input files and generate some output files. Next i tried to create a class to and using  getruntime and process to process this job. Even it compiled without error but when i run it just show the cursor blinking... i thought i need to use Thread async technique. please provide some advices since i do not have enough time for the projects. I also would like to implement a call back or return values when the job is done. an example would be greatly appreciated. Thanks </p>

<pre><code>import java.io.*;
 public class RunJob {

 // public static final String PROGRAM = "c:\\wrk\\java.exe Hello";

//one command line below
 public static final String PROGRAM = "c:/java.exe -cp \"wrk/jmp.jar;wrk/colt.jar\"   gov.lanl.yadas.reliability.UltimateMissileReliabilityModel 10000 \"wrk/\" x1.dat x2c.dat x3.dat   x4.dat x5.dat x6.dat true";

 //  Set to true to end the loop 
 static boolean done = false;

public static void main(String argv[]) throws IOException {

    BufferedReader is;   
    String line;
    String returnMsg = "Start ";
    final Process p = Runtime.getRuntime().exec(PROGRAM);
     System.out.println("start");


    Thread waiter = new Thread() {
      public void run() {
        try {
          p.waitFor();
        } catch (InterruptedException ex) {
        System.out.println("InterruptedException");
          return;
        }
        System.out.println("Program terminated!");
        done = true;
      }
    };
    waiter.start();
   is = new BufferedReader(new InputStreamReader(p.getInputStream()));

    while (!done &amp;&amp; ((line = is.readLine()) != null))
      {
      System.out.println(line);
      returnMsg = returnMsg + line;      
      } 
      System.out.println(returnMsg);
        System.out.println("End");

     return;
  }// main


}
</code></pre>
