Windows服务化安装jar

实现步骤

1、下载WinSW 64位:https://github.com/winsw/winsw/releases
2、将下载的WinSW.NET4.exe文件复制到jar程序所在文件夹中(我的jar包是research.jar)
3、将WinSW.NET4.exe重命名为research.exe(和jar同名)
4、在同目录下新建一个xml文件,命名为research.xml,写入以下内容


     research
     research
     research
     
     java
     -jar "C:\Users\lyr\Desktop\test\research.jar"
     Automatic
     D:logs\log
     rotate
 

5、xml补充说明

id,name,description我都写成了和jar包相同的名称
arguments:-jar后面写上自己jar包的路径
logpath:log文件路径

6、运行:以管理员运行cmd进入jar所在的目录,然后执行research.exe install

C:\Users\lyr\Desktop\test>research.exe install
Installing service 'research (research)'...
Service 'research (research)' was installed successfully.

7、出现上图的"Service 'research (research)' was installed successfully",表示服务安装成功,然后去Windows服务里面启动服务(服务名称是research)

卸载已经安装的服务

以管理员运行cmd进入jar所在的目录,然后执行research.exe uninstall

你可能感兴趣的:(Windows服务化安装jar)