java 调用dos命令行

大眼的小眼 2013-11-22 01:59:41
我想用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窗口,求大神帮忙
...全文
279 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
大眼的小眼 2013-11-25
  • 打赏
  • 举报
回复
求帮忙。。。
fyj_style 2013-11-22
  • 打赏
  • 举报
回复
同求 帮你顶顶
大眼的小眼 2013-11-22
  • 打赏
  • 举报
回复

就是这样请求的,
求帮忙
大眼的小眼 2013-11-22
  • 打赏
  • 举报
回复
这个是使用phantomjs截屏
tony4geek 2013-11-22
  • 打赏
  • 举报
回复
java 执行什么意思 , 直接打开
Runtime.getRuntime().exec("cmd.exe /c start http://www.amcharts.com/fiddle/?id=amcharts/tZyTN");
时光清浅 2013-11-22
  • 打赏
  • 举报
回复
比如我要打开D盘的qq.txe
  String command = "cmd /c start  d:qq.txt";
  Process child = Runtime.getRuntime().exec(command);
南猿北蛰 2013-11-22
  • 打赏
  • 举报
回复
没搞过,不知道,坐等别人回答....

51,409

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧