使用Runtime.getRuntime().exec(String[]cmdArray)时
代码如下:
- Java code
String[] cmdArray = { "cmd /c cd d:\\" }; Runtime.getRuntime().exec(cmdArray);
报异常信息如下:
java.io.IOException: Cannot run program "cmd /c cd d:\": CreateProcess error=2, ?????????
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
at lab.cmd.CmdTest.exec_strArr(CmdTest.java:19)
at lab.cmd.CmdTest.main(CmdTest.java:11)
Caused by: java.io.IOException: CreateProcess error=2, ?????????
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 4 more
请问这是怎么回事呢?
谢谢....
------解决方案--------------------