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.