问题
I am trying to run an external .exe program in Windows 7 from my Java code using ProcessBuilder
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();
However, when I run this standalone .exe from Windows using cmd it outputs the results in the command prompt as well as producing a file containing the results. I am not seeing any of these two happening while running the .exe from Java
Any kind suggestions what I am missing out?
回答1:
try to use this to set working directory :
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();
来源:https://stackoverflow.com/questions/17809295/running-windows-exe-file-with-multiple-arguments-using-java-processbuilder-is-n