• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Service Status

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your all replies.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic