我试图通过 procrun 使我的 java 应用程序成为 Windows 服务。但是当我启动服务时,出现以下错误:
2019-06-07 17:19:25 Commons Daemon procrun stderr initialized
java.lang.NoClassDefFoundError: SaveData
Caused by: java.lang.ClassNotFoundException: SaveData
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
2019-06-07 17:19:25] [error] [25304] FindClass SaveData failed
[2019-06-07 17:19:25] [error] [21836] Failed to start Java
[2019-06-07 17:19:25] [error] [21836] ServiceStart returned 4
[2019-06-07 17:19:25] [info] [ 8688] Run service finished.
[2019-06-07 17:19:25] [info] [ 8688] Commons Daemon procrun finished
有人能帮我吗?谢谢你
安装文件批处理
set SERVICE_NAME=TestService
set PR_INSTALL=C:\Users\sergi\Desktop\SaveData\prunsrv.exe
REM Service log configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=%~dp0%
set PR_STDOUTPUT=%~dp0%\stdout.txt
set PR_STDERROR=%~dp0%\stderr.txt
set PR_LOGLEVEL=Error
REM path to java installation
set PR_JVM=C:\Program Files\Java\jre1.8.0_191\bin\server\jvm.dll
set PR_CLASSPATH=C:\Users\sergi\Desktop\SaveData\testservice.jar
REM Startup configuration
set PR_STARTUP=auto
set PR_STARTMODE=jvm
set PR_STARTCLASS=SaveData
set PR_STARTMETHOD=main
REM Shutdown configuration
set PR_STOPMODE=jvm
set PR_STOPCLASS=SaveData
set PR_STOPMETHOD=main
REM JVM configuration
set PR_JVMMS=256
set PR_JVMMX=1024
set PR_JVMSS=4000
REM JVM options
set prunsrv_port=8080
set prunsrv_server=localhost
REM Install service
C:\Users\sergi\Desktop\SaveData\prunsrv.exe //IS//%SERVICE_NAME%