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);
}
}
}
0 comments:
Post a Comment