我可以使用 Apache Commons Daemon 工具安装、卸载和运行我的服务作为控制台应用程序。问题是当我尝试将我的应用程序作为服务运行时,服务状态不会从停止切换到运行。
用于安装服务的脚本:
prunsrv.exe install ServiceName --DisplayName="Some Display Name" --Classpath %cd%\daemon.jar --Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm --StartClass=Main --StartParams start --StopClass=Main --StopParams stop
我在 Windows 8 - 64 位中运行该服务。
对可能出现的问题有什么想法吗?
编辑: 在 services.msc 中运行应用程序时,我收到以下消息:
Windows could not start the [Service Name] service on Local Computer
Error 2: The system cannot find the file specified.
编辑2: 在 Windows 7-64 位中尝试过。同样的问题。
最佳答案
问题是 Windows 找不到 prunsrv.exe 文件。在安装文件夹中,必须指定可执行文件的完整路径。
关于java - Apache Commons Daemon - 无法启动服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25241550/