日期:2014-05-20  浏览次数:20657 次

java 调用dos命令行
我想用java执行phantomjs,但是发现我写的不行,
public static void invokeCmd() {
try {
// Execute command
String command = "cmd /c start cmd.exe";
Process child = Runtime.getRuntime().exec(command);

// Get output stream to write from it
OutputStream out = child.getOutputStream();

out.write("cd C:\\phantomjs-1.9.2-windows /r/n".getBytes());
out.flush();
out.write("phantomjs.exe nova.js http://www.amcharts.com/fiddle/?id=amcharts/tZyTN /r/n"
.getBytes());
out.close();
} catch (IOException e) {
}
}

他就弹出了一个dos窗口,求大神帮忙
------解决方案--------------------
没搞过,不知道,坐等别人回答....
------解决方案--------------------
比如我要打开D盘的qq.txe

  String command = "cmd /c start  d:qq.txt";
  Process child = Runtime.getRuntime().exec(command);

------解决方案--------------------
java 执行什么意思 ,
直接打开 
Runtime.getRuntime().exec("cmd.exe /c start http://www.amcharts.com/fiddle/?id=amcharts/tZyTN");

------解决方案--------------------
 同求  帮你顶顶