1. 将java工程打成jar包
2. 下载winsw:Releases · winsw/winsw (github.com)
3. 将WinSW.NET4.exe文件复制到jar包所在文件夹中
4. 将jar程序重命名,去掉名称中的“.”。例如HelloWorld-1.0.jar ----> HelloWorld.jar
5. 将WinSW.NET4.exe重命名为HelloWorld.exe(和jar同名)
6. 新建一个xml文件,命名为HelloWorld.xml,写入配置内容(可参考Github说明)
<service>
<id>HelloWorld</id>
<name>HelloWorld</name>
<description>This is HelloWorld service.</description>
<!-- java环境变量 -->
<env name="JAVA_HOME" value="%JAVA_HOME%"/>
<executable>java</executable>
<arguments>-jar -Dfile.encoding=utf-8