1.下载NSSM服务地址为:https://nssm.cc/ 你可以直接到我的csdn中下载。
https://download.csdn.net/download/weixin_42037607/85650606
2.编写intall.bat文件,注意根据操作系统版本选择64位或者32位。
nssm install MyApp %JAVA_HOME%\bin\java.exe
nssm set MyApp AppParameters -jar f:\REID\ss.jar
nssm set MyApp AppStdout f:\REID\log.log
nssm set MyApp AppStderr f:\REID\err.log
nssm set MyApp AppStopMethodSkip 6
nssm set MyApp AppStopMethodConsole 1000
nssm set MyApp AppThrottle 5000
nssm set MyApp DisplayName serialservice
nssm set MyApp start SERVICE_DELAYED_AUTO_START
nssm start MyApp
pause
注意本bat文件要与nssm的服务在同一个目录‘
3.运行bat文件,在服务中发现服务
4.但是不能启动。修改方法。打开注册表HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services找到你的服务。
把appDirectory更改。远来的不正确。
Application 也要更改。
5。更改后可启动