我试图运行java应用程序中的简单提示命令。无法在Java程序中执行提示命令
无论我尝试什么,我alwasy收到CreateProcess error=2
。
这是我的代码:
File f = new File("C:/Users/my/path/to/the/executable/");
String[] commands = { "text.txt", "--command1" /* others commands */ };
// omitting try/catch
Process p = Runtime.getRuntime().exec("myprogram.exe", commands, f);
p.waitFor();
// other code
的exe采用作为第一个参数为.txt文件,然后它需要正常的命令作为--command1。
我怎样才能得到这个工作?提前致谢!
你有什么错误? – talex
@talex,更具体地说是: Java.io.IOException:无法运行程序“myprogram.exe”(在目录“/ thedirectory”中):error = 2,没有这样的文件或目录 – Matteo