Is there a way to execute a command in java that doesn't suffer from the startup overhead (slowness) of using ProcessBuilder?
More detail: I am using im4java which is a java library that internally uses ProcessBuilder to execute imagemagick's programs. It is slow. I have created a small unit test that shows that ProcessBuilder (not im4java) is the problem. The slowness is the startup overhead of using ProcessBuilder. I have found posts around the internet saying processbuider has overhead so its not just me saying it does.
List<String> commands = new ArrayList<String>();
commands.add("C:\PROGRA~2\ImageMagick-6.6.4-Q16\convert.exe");
commands.add("dog.jpg");
commands.add("output.jpg");
ProcessBuilder processBuilder = new ProcessBuilder(commands);
Process start = processBuilder.start();
start.waitFor();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…