• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check an application running  RSS feed

 
jacob deiter
Ranch Hand
Posts: 588
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to write a java class to check whether an application running the machine or not, For Example, I want to check whether open office is running in my computer or not??.That java code expected to work in all OS.
 
James Basller
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacob deiter wrote:How to write a java class to check whether an application running the machine or not, For Example, I want to check whether open office is running in my computer or not??.That java code expected to work in all OS.


Hi,

I think for particular application you can make check by making program of monitoring port number is running or not. For example,
if there is a Tomcat running on 4099 port. So, one can make program to listen on that port and get this port's process is running or not.

Thanks!!!
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That won't work if the application is not using a port and you can't change it.

You'll need to either use JNI*, or use an external program. For Windows, that program is called "tasklist". Run "tasklist /? for possible options. For UNIX, that program is called "ps". Run "ps --help" or "man ps" for possible options. Also, please search and read the JavaWorld article "When Runtime.exec() won't".


* On UNIX, it's actually (also?) stored on the filesystem, in the /proc folder.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!