Java Windows Service with Procrun, StopMethod problem

Posted by mcdon on Stack Overflow See other posts from Stack Overflow or by mcdon
Published on 2010-03-24T23:49:23Z Indexed on 2010/03/24 23:53 UTC
Read the original article Hit count: 447

Filed under:
|
|

My Java class contains the following methods:

public static void main(String[] argv) //start the service

public static void stop() //stop the service

I'm using Procrun from Apache Commons Daemon to setup the Java class as a Windows Service. I get an error when I try to stop the service "[618 javajni.c] [error] Static method 'void main(String[])' in Class com/caphyon/service/JavaService not found". The problem is I am trying to call the stop method when the service is shutting down, but it appears to override the StopMethod with 'void main(String[])'. Here are the stop and start parameters I am using when setting up the service:

prunsrv.exe //US//JavaService --StartClass=com.caphyon.service.JavaService --StartMode=jvm --StartPath="C:\JavaService"

prunsrv.exe //US//JavaService --StopClass=com.caphyon.service.JavaService --StopMode=jvm --StopPath="C:\JavaService" --StopMethod="void stop()"

How do I set the StopMethod prunsrv will call when shutting down the service?

© Stack Overflow or respective owner

Related posts about windows-services

Related posts about java