1

I'm using the Apache Commons Exec jars for creating processes. However I'd like to get control of the process id of processes being invoked.

Is there a way of getting the 'Process' object from the Apache Commons Exec api? I did'nt fine any public methods that returns the 'Process class.

Matthew Farwell
  • 59,707
  • 18
  • 122
  • 168

1 Answers1

0

See http://commons.apache.org/exec/apidocs/index.html

Interface CommandLauncher contains several exec methods that return Process.

But anyway you do not have any way to control the process ID: it is the OS responsibility. Moreover standard java API does not allow you even to retrieve the process ID. There was a trick in older java versions: the implementation of Process contained int field pid that could be retrieved using reflection. But this was changed in version 1.6.

AlexR
  • 111,884
  • 15
  • 126
  • 200
  • Thanks for the information. The process object is related to another question I had asked here . I'm using JNA as described here [link](http://stackoverflow.com/questions/4912282/java-tool-method-to-force-kill-a-child-process/6032734#6032734) to retrieve the process id and kill the entire process tree using the taskkill command of windows. – Rajesh Kazhankodath Oct 02 '11 at 12:04