我正在尝试使用ProcessBuilder
从我的Java代码在Windows 7中运行外部.exe程序ProcessBuilder pb = new ProcessBuilder("C:\\hMetis\\1.5.3-win32\\hmetis.exe", "test.hgr", "2", "1", "10", "1", "1", "1", "0", "0");
Process process = pb.start();
但是,当我使用cmd从Windows运行此独立.exe时,它会在命令提示符下输出结果,并生成包含结果的文件。从Java
运行.exe时,我没有看到这两个中的任何一个发生我错过了哪些建议?
答案 0 :(得分:3)
尝试使用它来设置工作目录:
File f = new File("C:\\hMetis\\1.5.3-win32");
ProcessBuilder pb = new ProcessBuilder("cmd", "/c","start","hmetis.exe", "test.hgr", "2", "1", "10", "1", "1", "1", "0", "0");
pb.directory(f);
Process process = pb.start();