Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Runtime.getRuntime().exec(_;);_Java_Swing_Runtime_Ioexception - Fatal编程技术网

Java Runtime.getRuntime().exec(_;);

Java Runtime.getRuntime().exec(_;);,java,swing,runtime,ioexception,Java,Swing,Runtime,Ioexception,我对Java相当陌生,我正在创建我的第一个项目 无论如何-我正在尝试使用Runtime.getRuntime().exec(_;)执行位于同一文件夹中的另一个编译程序 问题是——当运行并输入程序其余部分的必要信息并到达执行点时,我会遇到一种错误 java.io.IOException: Cannot run program "\Italian": CreateProcess error=2, The system cannot find the file specified at java.la

我对Java相当陌生,我正在创建我的第一个项目

无论如何-我正在尝试使用Runtime.getRuntime().exec(_;)执行位于同一文件夹中的另一个编译程序

问题是——当运行并输入程序其余部分的必要信息并到达执行点时,我会遇到一种错误

java.io.IOException: Cannot run program "\Italian": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at Login.main(LOGIN.java:24)
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>(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 4 more

错误消息确切地告诉您出了什么问题——您到感兴趣的文件的路径是错误的。要找出正确的路径,请在程序中添加:

System.out.println("user dir path: " + System.getProperty("user.dir"));
然后使用相对于所示路径的路径


此外,意大利文件是否有扩展名,如.exe?否则,它将如何运行?调用
Runtime.getRuntime().exec(a)时,需要表示字符串的可执行集合,通常是数组或ArrayList,有时需要直接调用操作系统的命令。另外,作为一个补充,请考虑使用ProcessBuilder获取您的进程,不要忘记处理进程的流。

您运行的是什么操作系统、android、linux和windows

在android上,在终端中,如果是具有权限的二进制文件,则只需键入命令

如果它位于没有执行权限的驱动器(如SD卡)上,请键入“sh”


如果是windows,请在命令“c:/folder/runcmd.exe”

之前键入完整路径,每个选项取决于路径的位置-“使用”执行位于同一文件夹中的另一个编译程序,如果在编译的Java包中,请阅读Oracle教程部署-如何打包应用程序…,否则路径代码错误
System.out.println("user dir path: " + System.getProperty("user.dir"));