Windows下将JAVA jar注册成windows服务


下载Windows Service Wrapper

github下载

安装windows服务

  1. 将java jar包和下载的WinSW.NET4.exe放在同一个文件夹目录下面
  2. 重命名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\tanhw119214\Desktop\MyApp\MyApp.jar</arguments>
      <!-- 开机启动 -->
     <startmode>Automatic</startmode>
    <logpath>C:\Users\tanhw119214\Desktop\MyApp\logs</logpath>
    <log mode="roll-by-time">
    <pattern>yyyyMMdd</pattern>
    </log>
</configuration>

C:\Users\tanhw119214\Desktop\MyApp 为你要要注册服务的文件的父路径

4.进入根目录下面,执行以下cmd命令,注册服务。

MyApp.exe install 

然后在服务里面就能找到这个实例了。

启动命令

net start MyApp

停止命令

net stop MyApp

卸载命令

sc delete MyApp

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM