title: Open applications with Runtime.exec() on OS X
body: <p>How to open applications with Runtime.exec() on OS X?</p>
  
  <p>my instructor did give us an example of how to do it, except the only problem is that he uses Windows while I use Mac OS X, here is the code that I have customized so far:</p>
  
  <pre><code>public class Runtime_execution{
  public static void main(String args[]){
      Runtime rt = Runtime.getRuntime();
      Process proc;
      try{
          if(System.getProperty("os.name").startsWith("Mac OS X")){
  //                run an OS specific program
              proc = rt.exec("Contacts");
          }else{
              proc = rt.exec("gedit");
          }
          System.out.println("Before calling waitFor() method.");
          proc.waitFor(); //  try removing this line
          System.out.println("After calling waitFor() method.");
      }catch(Exception e){
          System.out.println("Contacts is an unknown command.");
      }
  }
  }
  // find out what the os name is for Mac OS X
  class Random{
  public static void main(String args[]){
      System.out.println(System.getProperty("os.name"));
  }
  }
  </code></pre>
  
  <p>When I ran the program, the output kept displaying: </p>
  
  <pre><code>Contacts is an unknown command. 
  </code></pre>
  
  <p>How can I fix this? </p>