You can use the below method to do that:
void setUpEnvironment(ProcessBuilder builder) {
Map<String, String> env = builder.environment();
// blah blah
}
Also, if your sub-processes are the same, then you don't need to go through this setup multiple times.
I hope this will help.
Want to become a Java Expert? Join Java Course now!!
Want to know more about Java? Watch this tutorial on Java Tutorial for Beginners | Java Tutorial: