如何使用winrun4j创建Windows服务
|
我一直在阅读文档,但是无法启动和停止服务。
我的.ini文件是:
main.class=test.TestService
service.class=test.TestService
service.id=StreamServer
service.name=StreamServer
service.description=Servidor que proporciona una comunicación con streams.
service.controls=stop
classpath.1=*.jar
TestService类是:
package test;
public class TestService{
private static TestServer server;
public static void main (String[] args){
if (args.length == 1){
if (args[0].equals (\"start\")){
if (server == null){
server = new TestServer (5000);
server.start ();
}
}else if (args[0].equals (\"stop\")){
if (server != null){
server.stop ();
server = null;
}
}
}
}
}
我必须修改此类,但我不知道如何。
谢谢。
没有找到相关结果
已邀请:
1 个回复
邪罗逢确胃
服务启动时将调用serviceMain方法。在服务准备关闭之前,您不应从此方法返回。还要检查\“ shutdown \”标志-单击服务控制面板中的“停止”时(或需要停止服务时),该标志将设置为true。