How to Open Command Prompt Mode Console (CMD) Console from Java Code

This is a simple and an interesting Java Program code through which you can easily open the command prompt (CMD) mode easily.

Source Code 


package packaga.sixteen;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 *
 * @author Shan
 */
public class cansole {
/**
     * @param args the command line arguments
     */
public static void main(String[] args) {
try {
Process p = Runtime.getRuntime().exec("cmd /c start cmd.exe");
p.waitFor();
} catch (IOException ex) { // import java.io.IOException;
Logger.getLogger(cansole.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(cansole.class.getName()).log(Level.SEVERE, null, ex);
}
}
}


Output of the Program

 Open Command Prompt Mode Console (CMD) Console from Java Code

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment