下载Windows Service Wrapper
github下载
安装windows服务
- 将java jar包和下载的WinSW.NET4.exe放在同一个文件夹目录下面
- 重命名WinSW.NET4.exe为MyApp.exe(这个可以任意取),新建个MyApp.xml(这个必须和前者的exe文件名字相同)
编辑MyApp.xml文件
<configuration> <id>MyApp</id> <name>MyApp</name> <description>This is MyApp.</description> <executable>java</executable> <arguments>-jar C:Users anhw119214DesktopMyAppMyApp.jar</arguments> <!-- 开机启动 --> <startmode>Automatic</startmode> <logpath>C:Users anhw119214DesktopMyApplogs</logpath> <log mode="roll-by-time"> <pattern>yyyyMMdd</pattern> </log> </configuration>
C:Users anhw119214DesktopMyApp 为你要要注册服务的文件的父路径
4.进入根目录下面,执行以下cmd命令,注册服务。
MyApp.exe install
然后在服务里面就能找到这个实例了。
启动命令
net start MyApp
停止命令
net stop MyApp
卸载命令
sc delete MyApp