更强力的Windows Service Wrapper工具 -- WinSW

和Java Service Wrapper一样,WinSW也可以将java的jar程序转为windows服务,而且:

  • 配置文件更精简直观
  • 运行更简便
  • 免费开源!

1、下载:

可以直接在GitHub上下载:

https://github.com/kohsuke/winsw

225133_9KVZ_2920923.png

鉴于墙的原因,并不是随时都能够在GitHub上下载,这里提供百度云链接:

链接:http://pan.baidu.com/s/1cxT2F0

密码:ewzm

2、使用步骤:

2.1、更改文件名

更改MyApp.xml和MyApp.exe文件名,改成什么不重要,重要的是两个文件的文件名要保持一致

          232053_tyW0_2920923.png

更改文件名后,将jar包拷到目录下:

         232803_L1lI_2920923.png

2.2、更改MyApp.xml配置文件

<service>
  <!--id、name、description为服务信息-->
  <id>MyApp</id>
  <name>MyApp</name>
  <description>This is MyApp!!</description>
  <!--executable标签和argument标签加起来相当于在控制台输入java -jar 当前目录/MyApp.jar-->
  <executable>java</executable>
  <arguments>-jar "%BASE%\MyApp.jar"</arguments>
  <!--配置log模式-->
  <logmode>rotate</logmode>
</service>

更多的XML配置信息可以在GitHub上查看:

https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md

2.3、运行

2.3.1、安装服务

以管理员模式打开控制台(如果不以管理员模式打开,可能报AssessDenied异常),然后输入命令:

MyApp.exe install

就可以将jar转为windows服务并注册。

然后在服务列表中启动服务即可。

2.3.2、卸载服务

输入命令:

MyApp.exe uninstall

即可将安装好的windows服务卸载。

2.3.3、其他命令

  • start to start the service. The service must have already been installed.
  • stop to stop the service.
  • restart to restart the service. If the service is not currently running, this command acts like start.
  • status to check the current status of the service.

转载于:https://my.oschina.net/pierrecai/blog/895336

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值