1

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?

1
  • You should add the Java bin directory to your system PATH variable (it's probably just in your user variable at the moment). Or specify the full path of java.exe instead of just "java". Commented Jun 20 at 13:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.