class RuntimeDemo
{
public static void main(String[] args) throws Exception
{
Runtime r = Runtime.getRuntime();
r.exec("winmine.exe");
}
}
D:\javad\day18>java RuntimeDemo
Exception in thread "main" java.io.IOException: Cannot run program "winmine.exe"
: CreateProcess error=2, ?????????
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at RuntimeDemo.main(RuntimeDemo.java:18)
Caused by: java.io.IOException: CreateProcess error=2, ?????????
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 4 more作者: 张超超 时间: 2012-4-17 11:27
报出这个错误:D:\javad\day18>java RuntimeDemo
Exception in thread "main" java.io.IOException: Cannot run program "winmine.exe"
说明无法运行winmine.exe这个,你看下你是否将winmine.exe文件的路径配置到path中了,或者放到了D:\javad\day18这个目录中了。作者: 韩新凯 时间: 2012-4-17 11:42
这就是我的异常信息,对于这个问题的解决方式,很简单。