Windows Service Wrapper

Copyright: LeifChen original, please indicate the source, thank you ~ https://blog.csdn.net/leifchen90/article/details/85128095

Windows Service Wrapper

Windows Service Wrapper Java jar package can be registered as a windows service.

download

Official GitHub download WinSW.NET4.exe and sample-minimal.xml

Configuration

The executable jar package and download winsw in the same directory, and change the name to be consistent, for example MyApp.

image

Change MyApp.xml configuration file:

<configuration>
    <id>MyApp</id>
    <name>MyApp</name>
    <description>This is MyApp.</description>
    
    <executable>java</executable>
    <arguments>-jar "%BASE%"\MyApp.jar</arguments>
    
    <logpath>%BASE%\logs</logpath>
    <log mode="roll-by-time">
    <pattern>yyyyMMdd</pattern>
    </log>
</configuration>

run

Registration 1 / unloading services

Run as administrator CMD command window, enter the command jar can be registered as a windows service

MyApp.exe install     # 注册服务
MyApp.exe uninstall  # 卸载服务

2 Start / Stop Service

In the CMD command window, enter the command to start the service, or My Computer, right management, start the service in the list of services.

MyApp.exe start     # 启动服务
MyApp.exe stop     # 停止服务
MyApp.exe restart  # 重启服务
MyApp.exe status   # 查看服务运行状态

reference

  1. Official GitHub repository

Guess you like

Origin blog.csdn.net/leifchen90/article/details/85128095