0

I am running a set of Java applications through batch files which occasionally need to be killed via console. But in task manager it shows all these applications as java.exe, whereas in the application tab it shows the particular name. I need to get the process id for the application from the application tab, so that I can kill the application based on it. To reiterate, I have only the application name, not other details, and how would I obtain the PID based on this - in vb.net?

Thanks In Advance

Regards Sathya.M

Perception
  • 79,279
  • 19
  • 185
  • 195
Sathya
  • 103
  • 7
  • Good point. (+1). Completely forgot about jps. – AlexR Feb 28 '12 at 11:39
  • start class of all java application has same name. but i didn't know about jps. how to do it? – Sathya Feb 28 '12 at 12:05
  • @Sathya: http://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/jps.html – RanRag Feb 28 '12 at 12:12
  • I changed batch files title like start "myexample" java -jar ... likewise. Then to stop that applications. first i stored all java applications in one array. Then i checked its mainwindowtitle as equal to myexample. Then i kill that process. its working well. – Sathya Jul 25 '13 at 06:54

1 Answers1

3

Take a look on this thread: How can a Java program get its own process ID?

This is not exact duplicate. It answers the question how can application discover PID of itself.

If all applications you are running are yours you can modify your code to read the PID and pass it to other process (e.g. by writing it to file). If the process is not yours you can anyway use JMX to connect to your applications remotely and discovery their PIDs.

Community
  • 1
  • 1
AlexR
  • 114,158
  • 16
  • 130
  • 208