我正在尝试使用java打开exe文件。我不确定要打开哪个程序,因此我使用 Skype 作为示例。当我尝试这样做时,它给了我错误。
try {
Process p = Runtime.getRuntime().exec("C:\\Program Files (x86)\\Skype\\Phone\\Skype");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
错误:无法运行程序“C:\Program”: CreateProcess error=2,系统找不到指定的文件
尝试这个:
String path = "/path/to/my_app.exe";
File file = new File(path);
if (! file.exists()) {
throw new IllegalArgumentException("The file " + path + " does not exist");
}
Process p = Runtime.getRuntime().exec(file.getAbsolutePath());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20632 次 |
| 最近记录: |