wood burning stoves*
The moose likes Beginning Java and the fly likes Service Status Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Service Status" Watch "Service Status" New topic
Author

Service Status

Raveendra Kumar
Greenhorn

Joined: Dec 20, 2005
Posts: 12
Hi all

I want to write a java program that checks the status of a particular service (whether its running or not). If service is not running then i want to run that service. Is it possible in java?
If so, please guide me with where to start with. Any api or links will be greatly appreciated.

regards
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
Services written by you? If yes, write/run them as threads, and check if the thread has terminated or not (like serviceThread == Thread.State.TERMINATED.)

This should help?


ASCII silly question, Get a silly ANSI.
Raveendra Kumar
Greenhorn

Joined: Dec 20, 2005
Posts: 12
Thanks for your reply.
I am working on linux. I have one c++ program which i wrote, i am running this as a service.
Now i want to write a java program that checks whether is service is up or down. If service is down, then i want to restart this service.
Now as per your reply, i didnt understand your reply.
how to create a service thread?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Java was not designed to deal with environment specific stuff like OS services.


[My Blog]
All roads lead to JavaRanch
Raveendra Kumar
Greenhorn

Joined: Dec 20, 2005
Posts: 12
Satou kurinosuke:

So you say its not possible in java to know whether any user created service is running or not?

But reply of Stuart Ash says its possible

i am confused
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
I only meant "service" in the generic sense. If you have OS-specific interaction, that will be another story. I was not covering that in my reply.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Making a system call with Runtime.exec() ?

Look this out to avoir problems :
Runtime.exec() traps

Using JNI with a C++ class is another possibility. Never tried this.
[ December 27, 2005: Message edited by: Satou kurinosuke ]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
You can use Java to "talk" JNI to a custom C++ module which can then do anything C++ can do on your system. It won't be portable to Windows of course but you may be lucky enough to not care.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Raveendra Kumar
Greenhorn

Joined: Dec 20, 2005
Posts: 12
Thanks for your all replies.
 
jQuery in Action, 2nd edition
 
subject: Service Status