0

これは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()はそれを認識していないようです。

それを修正するにはどうすればよいですか?ありがとう

4

1 に答える 1

0

「コマンドラインアプリ」の代わりにCommandLineAppsを使用するなど、スペースを含まないフォルダ名を使用してみてください

于 2012-10-17T09:37:09.580 に答える