On the JavaDoc for ProcessBuilder it states
The methods that create processes may not work well for special processes on certain native
platforms, such as native windowing processes, daemon processes, Win16/DOS processes on
Microsoft Windows, or shell scripts.
My main question is what about ProcessBuilder does not work well with daemon processes? What about ProcessBuilder doesn’t lend itself to being an acceptable way of launching these types of applications?
Thanks!
My guess (based on the comments I found in code grep) is that the issue is with the fact you have to handle the streams of the process and that this handling might be an issue.
It may also be related to the fact that
Processis an abstract class and every JRE/JDK carries with it it’s own platform dependent process implementation (e.g.UNIXProcess,WindowsProcessetc.) Some operating systems might simply have limitations related to opening processes which Java cannot cover in its documentation.Again – this is just a guess, the code does’t reveal much.
From my experience (both on *nix systems and windows) – your code needs to be platform aware most of the time in how you construct your command line, how you provide arguments (either in the
argumentsparameter or in the command line) and how you build the environment of the spawned process (inherit your process’s values or create on of your own). It is more a game of trial and error in any case.