• Post Reply Bookmark Topic Watch Topic
  • New Topic

Controlling and starting processes.  RSS feed

 
Greenhorn
Posts: 27
Firefox Browser MyEclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai.
I am writing a java program that requires me to search the running processes and see if a given process is alive and then get the path of that process.How can i do that
eg:-
if the process is explorer.exe then i must get its path as C:\Windows\explorer.exe
 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing in Java alone will do that. You will have to use JNI and system - dependent code. To get the list of all processes there are command-line option to use (ps or Linux, tasklist on Windows), but as far as I know (on Windows at least) they don't provide the path to the process itself. So you would need to use native code for that.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To elaborate a little on the 'command-line' options:

You can execute command line options using ProcessBuilder (or the Runtime object). When you do, make sure you read up on how to properly use / consume the response: When Java.Runtime() won't.

Additionally, you would need to research the appropriate command line to send for your needs and OS.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!