I have a spring boot application jar and I'm trying to install this as a windows service and start automatically, using winsw.
My xml for winsw:
<service>
<id>myservice</id>
<name>myservice</name>
<description>My application</description>
<executable>cmd.exe</executable>
<arguments>start-application.bat</arguments>
<startmode>Automatic</startmode>
<workingdirectory>.</workingdirectory>
<logpath>logs</logpath>
<log mode="roll-by-size">
<sizeThreshold>10240</sizeThreshold>
<keepFiles>5</keepFiles>
</log>
<stdout>stdout.log</stdout>
<stderr>stderr.log</stderr>
<onfailure action="restart" delay="15000"/>
<shutdown>graceful</shutdown>
</service>
The start-application.bat file contains the jar to be executed, since the version of jar is put in during runtime.
@echo off
echo Starting Java app... > log.txt
java -Dloader.path=lib -jar %~dp0myapp-234-jar-with-dependencies.jar >> log.txt 2>&1
echo Started >> log.txt
Although the service seems to start, but the application itself is not started since there is an error in the log.txt file:
Starting Java app...
'java' is not recognized as an internal or external command,
operable program or batch file.
Started
What do i need to change to start the spring boot application as windows service and see the logs in log.txt file?