MyRuntime.exec()说找不到文件

时间:2012-10-17 09:24:09

标签: java runtime.exec external-process

这是JAVA编程语言问题

这是我试图执行的代码:

MyRuntime = Runtime.getRuntime();
File temp = new File("C:\\Command Line Apps\\cURL\\");
for(String filenames : temp.list()) System.out.println(filenames);
curl = MyRuntime.exec("curl.exe", null, temp);

输出结果为:

java ScreenshotMaker

build.txt
CHANGES
COPYING
curl.exe
curl.html
curl.pdf
libcurl.dll
libeay32.dll
libidn-11.dll
libssl32.dll
mk-ca-bundle.vbs
README
RELEASE-NOTES
_curlrc
Exception in thread "main" java.io.IOException: Cannot run program "curl" (in di
rectory "C:\Command Line Apps\cURL"): CreateProcess error=2, The system cannot f
ind the file specified

如您所见,curl.exe存在于目录中。 但 Runtime.exec()似乎无法识别它..

我该怎么做才能修复它? 感谢

1 个答案:

答案 0 :(得分:0)

尝试使用没有空格的文件夹名称,例如使用CommandLineApps而不是“命令行应用程序”