Java Language Process ch.vorburger.exec

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


Launching external processes from Java using the raw java.lang.ProcessBuilder API directly can be a little cumbersome. The Apache Commons Exec library makes it a little easier. The ch.vorburger.exec library further extends upon Commons Exec to make it truly convenient:

 ManagedProcess proc = new ManagedProcessBuilder("path-to-your-executable-binary")
     .setWorkingDirectory(new File("/tmp"))

int status = proc.waitForExit();
int status = proc.waitForExitMaxMsOrDestroy(3000);
String output = proc.getConsole();

proc.startAndWaitForConsoleMessageMaxMs("started!", 7000);
// use service offered by external process...

Got any Java Language Question?