gpt4 book ai didi

java - 处理方法不执行所需程序

转载 作者:行者123 更新时间:2023-11-29 05:36:52 31 4
gpt4 key购买 nike

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的程序吗?

最佳答案

enter image description here

这是dos的图片...

关于java - 处理方法不执行所需程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19207538/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com