我的代码如下 - public static void testRuntime() throws Exception{
- Runtime r = Runtime.getRuntime();
- Process p = r.exec("D:\\1.txt");
- Thread.sleep(4000);
- p.destroy();
- }
复制代码
异常信息是
- Exception in thread "main" java.io.IOException: Cannot run program "D:\1.txt": CreateProcess error=2, ?????????
- at java.lang.ProcessBuilder.start(Unknown Source)
- at java.lang.Runtime.exec(Unknown Source)
- at java.lang.Runtime.exec(Unknown Source)
- at java.lang.Runtime.exec(Unknown Source)
- at Test.Test2.testRuntime(Test2.java:17)
- at Test.Test2.main(Test2.java:9)
- Caused by: java.io.IOException: CreateProcess error=2, ?????????
- at java.lang.ProcessImpl.create(Native Method)
- at java.lang.ProcessImpl.<init>(Unknown Source)
- at java.lang.ProcessImpl.start(Unknown Source)
- ... 6 more
复制代码 |