如何从java程序执行irfan view命令...?

时间:2014-05-01 14:41:34

标签: java

我正在尝试从Java程序执行以下命令..

C:\Program Files (x86)\IrfanView>i_view32.exe D:\irfan_view_cmd\test.jpg /jpgq=75 /aspectratio /resample /convert=D:\irfan_view_cmd\test.jpg

从命令提示符执行时有效,但从java程序运行时出错:

错误:

 Exception in thread "main" java.io.IOException: Cannot run program "C:\Program": CreateProcess error=2, The system cannot find the file specified

Java代码:

    String WIN_PROGRAMFILES = System.getenv("programfiles");
    System.out.println(WIN_PROGRAMFILES);

    String command = WIN_PROGRAMFILES + "\\IrfanView\\i_view32.exe D:\\irfan_view_cmd\\test.jpg /jpgq=75 /aspectratio /resample /convert=D:\\irfan_view_cmd\\test.jpg";
    System.out.println(command);
    Process p = Runtime.getRuntime().exec(command);
    p.waitFor();
    System.out.println("Process exitValue : " + p.waitFor() + "\n" + "Command :" + command);

0 个答案:

没有答案