//p.exitValue() 是它的结束符,p.waitFor()用来等待程序结束。import  java.lang.*;  
import  java.io.*;  
 
public  class  testmyprogram    
     {  
         public  static  void  main(String  args[])  
             {  
               Process p = null;
               try{  
                     p =Runtime.getRuntime().exec("notepad.exe");    
                     //p.waitFor();
                     System.out.println(p.exitValue());
                     }  
               catch(Exception  e){  
                     System.err.println(  "Program has not exited.");  
                     try{
                      p.waitFor();
                     }catch(InterruptedException ee){
                     
                     }
                     System.err.println(  "Program has exited.");
               }          
     
               //return;    
             }  
     }