public class test2 {
public static void main(String[] args) {
try {
// print a message
System.out.println("Executing VLC.exe");
Process process = Runtime.getRuntime().exec("C:\\Program Files\\VideoLAN\\VLC\\vlc.exe");
// print another message
System.out.println("VLC should now open.");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
这是错误:
Cannot run program "C:\Program": CreateProcess error=2, The system cannot find the file specified
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 test2.main(test2.java:21)
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>(Unknown Source) at
java.lang.ProcessImpl.start(Unknown Source) ... 5 more***
但是这个程序很容易运行 notepad.exe 和相关的文本文件。那么它只能在Win32下运行程序吗?