读书人

为何这个程序不能打开计算器

发布时间: 2012-06-20 20:37:21 作者: rapoo

为什么这个程序不能打开计算器
package org.tgl;

public class RuntimeDemo {

public static void main(String[] args) {
Runtime run = Runtime.getRuntime();
try{
run.exec("caculator.exe");
}
catch (Exception e){
e.printStackTrace();
}
}

}

[解决办法]
runtime.exec("cmd /c start calc.exe ");

Java code
package org.tgl;public class RuntimeDemo {public static void main(String[] args) {Runtime run = Runtime.getRuntime();try{run.exec("cmd   /c   start    calc.exe "); }catch (Exception e){e.printStackTrace();}}}
[解决办法]
run.exec("calc.exe");
试试。

读书人网 >Eclipse开发

热点推荐