我已經創建了一個Java應用程序(運行無限循環)(與許多Java類文件),也使用log4j.jar
和`snmp4j.jar? 。爲了運行應用程序,我需要按以下方式提供一些輸入參數:使用JavaService添加Windows服務
C:\APP>java myApp.class arg1 arg2 arg3 arg4 arg5 arg6
其中myApp.class
包含主處理器。
此應用程序在命令行執行下正常工作。但是,我想爲此應用程序創建一個Windows服務,以便它在PC啓動時運行。另外,如果服務因任何原因而關閉,它將在Windows服務工具下重新啓動。
我試圖用JavaService我的目的,通過執行以下命令:
C:\APP>JavaService.exe -install MyService "C:\java\jdk1.6.0.29\jre\bin\server\jvm.dll" -start myApp.class -params arg1 arg2 arg3 arg4 arg5 arg6
The MyService automatic service was successfully installed
我可以看到我的MyService
下管理工具 - >服務出現
然而,當我做了它開始然後停止:(
Service dialog:
The MyService on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service.
A尼永知道爲什麼?
創建服務時,請嘗試「-err D:\ Logs \ javaservice.log」,它會告訴你哪個庫丟失,並且需要使用-Djava.class.path = something.jar添加 – 2013-08-09 17:03:11