当前位置: 技术问答>java相关
怎样用Java调用window命令或启动其它程序?
来源: 互联网 发布时间:2015-04-18
本文导语: 我想用Java程序编译,运行另外一个java程序,不怎样实现,请高手指教! | 例如: Runtime.getRuntime.exec(new String[]{"javac","HelloWorld.java"}); // Runtime.getRuntime.exec(new String[]{"java","HelloWorld"}); | ...
我想用Java程序编译,运行另外一个java程序,不怎样实现,请高手指教!
|
例如:
Runtime.getRuntime.exec(new String[]{"javac","HelloWorld.java"});
//
Runtime.getRuntime.exec(new String[]{"java","HelloWorld"});
Runtime.getRuntime.exec(new String[]{"javac","HelloWorld.java"});
//
Runtime.getRuntime.exec(new String[]{"java","HelloWorld"});
|
Runtime runTime=Runtime.getRuntime();
runTime.exec("javac XXX.java");
runTime.exec("java XXX");
runTime.exec("javac XXX.java");
runTime.exec("java XXX");