From how-do-i-set-environment-variables-from-java
A possible way to ease the burden would be to factor out a method
void setUpEnvironment(ProcessBuilder builder) {
Map env = builder.environment();
// blah blah
}
and pass any ProcessBuilders
through it before starting them.
Also, you probably already know this, but you can start more than one process with the same ProcessBuilder
. So if your subprocesses are the same, you don't need to do this setup over and over.