I just wanted to bring to your attention a few pitfalls of
Runtime.exec() that is used to launch external processes from Java:
This is an old article but still true. I ran into the 2nd pitfall when
adding some external process invocations to GlobalPlugin: An external
process which writes a lot to the output and/or error streams can be
blocked if the Java process that launched it does not consume these
streams. In my case, I run "global.exe -u" to update the database, and
I am not interested in neither of these streams; nevertheless, I must
empty those streams or the "global.exe" process hangs because of OS
buffering. When the OS buffer for the output/error stream becomes
full, and the process wants to write more into it, it is blocked until
the buffer is consumed.
And since two output streams are involved here, they cannot be
consumed sequentially, because you don't know which will cause the
process to block first; the ideal solution is to use two separate
threads, each consuming one of these output streams.