Reputation: 54084
I need from a java process to call external processes/scripts/cli commands.
Since these calls will be quite a lot and some will return back the result of the process/script that run and others will just run it, I was wondering if:
ProcessBuilder
so that I don't have scattered in the code calls to ProcessBuilder
constantlyfinal String
in the code?Upvotes: 1
Views: 77
Reputation: 14863
Your question is a little bit vague to write a precise answer but I have some suggestions:
launch
method to start a process and capture stdout and stderr (in two threads), to write a log of your driver.If I try to classify your problem, I think mainly at Control flow.
To resolve a large problem you may use parallelism: launch concurrently several processes and wait for the termination of all of them: it's a rendez-vous or join phase. You may launch remote command to another networked computer, perhaps.
A good example to how to specify parallelism into an XML file is ANT build files:
<parallel>
<wlrun ... >
<sequential>
<sleep seconds="30"/>
<junit fork="true" forkmode="once" ... >
<wlstop/>
</sequential>
</parallel>
Can I suggest you to use ANT to solve your problem without programming?
A drawing of wished execution may help, with a paper and a pen... ;-)
Several graphical applications may help to draw the logical diagram of control flow. Once done, publish it here and you'll obtain more precise answer, I hope...
Upvotes: 2