0

In Java program I've object of Process, I want to know it's PID. Program is running on Windows 64-bit machine. I've come across this, but couldn't make them work.

I need PID of process, because I want to kill the process if it's still running) after timeout. Process#destroy doesn't kill subprocesses.

Community
  • 1
  • 1
user148865
  • 326
  • 1
  • 5
  • 19
  • I hope you need to browse through http://stackoverflow.com/questions/35842/how-can-a-java-program-get-its-own-process-id This id would help you with sample code as well http://stackoverflow.com/questions/5284139/how-do-i-find-the-process-id-pid-of-a-process-started-in-java – Saurabh Jhunjhunwala Apr 29 '15 at 05:53
  • @SaurabhJhunjhunwala: First one discusses about **PID of Java program itself, and not process spawned from it**, in second no answer provided particular way for windows 64-bit machine. – user148865 Apr 29 '15 at 05:55
  • @MadProgrammer: Yes, it doesn't kill subprocesses of Process. Edited question to make it more clear. – user148865 Apr 29 '15 at 06:02
  • Ah,okay. You will need a JNI/JNA solution, maybe something like [this](http://cnkmym.blogspot.com.au/2011/10/how-to-get-process-id-in-windows.html) – MadProgrammer Apr 29 '15 at 06:07

0 Answers0