Java属性allowAmbigousCommands在Windows7,7u2532bJRE上不适用于我:
System.setProperty("jdk.lang.Process.allowAmbigousCommands", "true");
try {
Process p= Runtime.getRuntime().exec("foo.bat > myOutput.txt");
} catch (IOException e) {
e.printStackTrace();
}其中foo.bat的内容是:
回音“你好世界”
我还检查了使用-Djdk.lang.Process.allowAmbigousCommands=true,但没有成功。有线索吗?
提前谢谢。
发布于 2013-06-29 23:12:45
jdk.lang.Process.allowAmbigousCommands不会帮助执行批处理文件。
运行exec()作为
Runtime.getRuntime().exec("cmd /C \"foo.bat > myOutput.txt\"");参考
https://stackoverflow.com/questions/17385447
复制相似问题