I am writing a java program on windows platform. I need to compress certain files into a zip archive. I am using ProcessBuilder to start a new 7zip process:
ProcessBuilder processBuilder = new ProcessBuilder("7Z","a",zipPath,filePath);
Process p = processBuilder.start();
p.waitFor();
The problem is that the 7zip process never exits after completion. It does create the required zip file but after that just hangs in there. This means that the waitFor() call never returns and my program gets stuck. Please suggest a fix or a work around.
here is what I ended up doing.
I can’t set enviroment variables so I had to set the c: path for 7zip.
The convert to string function can be found here which is what I used as a reference. http://singztechmusings.wordpress.com/2011/06/21/getting-started-with-javas-processbuilder-a-sample-utility-class-to-interact-with-linux-from-java-program/