0

hi i have changed a java process as the windows service. but in this whenever i am starting the windows service two java processes are running.it is spoiling my work totally can we have any way to remove a java process?

4
Contributors
3
Replies
10
Views
2 Years
Discussion Span
Last Post by JamesCherrill
0

when the process starts, update a local kept file (bit like the system of a cookie) and set a value for key 'running' to true. right before terminating, set the value to false.

each time you start it, first make sure the current value is false, otherwise, don't start. this does may cause troubles if the applications terminates unexpectedly, though

0

Or how did you start the process? If you use windows scheduler, you should be able to set for only one process running. If you manually start or use a script to run (not windows scheduler), stultuske would be the way to go (even though you catch all exceptions, you still have problem if there is a blackout or user turns off the computer without closing your program).

0

With a file, sooner or later it's inevitable that the program will terminate abnormally in some way, leaving the file in the wrong state.
You could open a ServerSocket (a concurrent second attempt will throw a BindException), which has the advantage that the port should be released whenever the JVM terminates, or the user is logged off, or the computer restarts.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.