title: How to open cmd.exe in java
body: <p>I have seen several topics about this but i havent got i to work. 
  All i am trying to do is open cmd.exe from a java program.</p>
  
  <p>notepad.exe opens fine.</p>
  
  <p>The problem is that cmd.exe dosent open, the code compiles fine with no error</p>
  
  <p>here is my code:</p>
  
  <pre><code>public class CMD {
  
  public static void main(String[] args) {
  
    //Trying some variants how to start. 
  
    //String cmd = "C:\\WINDOWS\\system32\\cmd.exe";
    //String[] cmd = {"C:\\WINDOWS\\system32\\cmd.exe","start"};
  
    String[] cmd = {"C:\\WINDOWS\\system32\\cmd.exe","/c","start"};
  
     // notepad works fine
     //String notepad = "C:\\WINDOWS\\system32\\notepad.exe";
  
  
   try {        
      Runtime runtime = Runtime.getRuntime();
      //Process p = runtime.exec(notepad);
      Process p = runtime.exec(cmd);
  
  
   }
  
  catch (java.io.IOException exception) {
      System.out.println("Caught IOException: " + exception.getMessage());
  
      }
  }
  }
  </code></pre>