Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Service Status

 
Raveendra Kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Raveendra Kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java was not designed to deal with environment specific stuff like OS services.
 
Raveendra Kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raveendra Kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your all replies.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic