我使用以下代码运行cmd.exe,然后出现cmd窗口,这很好。
boolean movePlayerWithMouse = false;
while(Keyboard.next()) {
if(!Keyboard.getEventKeyState()) {
if(Keyboard.getEventKey() == Keyboard.KEY_TAB) {
movePlayerWithMouse = !movePlayerWithMouse;
Mouse.setGrabbed(!Mouse.isGrabbed());
}
}
}
if(movePlayerWithMouse = !movePlayerWithMouse) {
rotY -= Mouse.getDX() / SENSITIVITY;
}
我的问题是如何在使用java之前在cmd上运行以下命令
Runtime runtime = Runtime.getRuntime();
try {
Process p = runtime.exec("cmd.exe /c start");
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
我的目标是让命令行看起来像下面的图像
答案 0 :(得分:2)
运行
Runtime runtime = Runtime.getRuntime();
try {
Process p = runtime.exec("start cmd.exe /k \"ghci.exe test.hs\"");
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
referens http://ss64.com/nt/cmd.html
How to open the command prompt and insert commands using Java?
的更多信息