这有什么区别 -
Process process=Runtime.getRuntime().exec(
new String[] {"cmd", "/c", command.toString()},
null, new File("D:/test"));
和 -
Process process=Runtime.getRuntime().exec(
command.toString(), null, new File("D:/test"));
如果我使用第一个它正在工作,但如果我使用第二个,它会给出以下异常 -
java.io.IOException: Cannot run program "gst" (in directory "D:\test"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:450)
at CommandInvoker.main(CommandInvoker.java:38)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:385)
at java.lang.ProcessImpl.start(ProcessImpl.java:136)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 3 more