Well, Commons Exec relies on the Java Process class, which does not provide PIDs. This is also what is used to kill the process, so you cannot change the behavior. Everything is beautiful and encapsulated. Gotta love OO, huh?
If you just run processes in the background, you can wrap them in a simple shell script that captures the PID for you, and then saves it to a “known place” that your Java routine knows about. It’s still messy, and naturally, it’s not well ported to other platforms.
You can write your own exec function using JNI to capture this information for you, but it is probably less friendly.
, , - (C, Python ..). - , . , JVM ( JVM).
( ). INelegant, ( , , Windows vs Unix Java , ), JNI.