window系统用winsw将jar包做成后台服务

1、下载winsw.exe
winsw.exe文件下载路径:https://github.com/winsw/winsw/releases
在这里插入图片描述

2、编写配置文件sample.xml

sample
sample
This service runs sample system.
java
-Xrs -Xmx256m -jar “%BASE%\sample.jar”


3、修改为同样的名称
把sample.jar、sample.xml、winsw.exe 放到同一目录,并且修改为和jar包同样的名称
修改前
在这里插入图片描述
修改后:
在这里插入图片描述
4、安装sample服务

打开CMD命令行,并切换到jar所在目录,运行 sample install 命令进行服务安装
在这里插入图片描述
此时就可以在后台中查看windows服务了。但是此时程序还是未启动状态
在这里插入图片描述
5、启动服务

1)界面启动:在sample服务上面右键,选择启动。或者双击sample服务,打开属性窗口,点击启动。

在这里插入图片描述
在这里插入图片描述
2)命令行启动

切换到jar包所在目录运行 sample start

在这里插入图片描述
6、其他一些命令行操作指令

install install the service to Windows Service Controller

uninstall uninstall the service

start start the service (must be installed before)

stop stop the service

stopwait stop the service and wait until it’s actually stopped

restart restart the service

restart! self-restart (can be called from child processes)

status check the current status of the service

test check if the service can be started and then stopped

testwait starts the service and waits until a key is pressed then stops the service

version print the version info

help print the help info (aliases: -h,–help,-?,/?)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值