2

I have spring boot executable jar file which can run into any command prompt by calling java -jar filename.jar.

I want to create a service with out downloading any external libraries for the above code snippet.

Help me if there is a strait forward way.

2
  • What OS? What version?
    – ETL
    Apr 6, 2022 at 4:01
  • Its windows 10 pro
    – Khaled
    Apr 7, 2022 at 8:30

1 Answer 1

2

Simple (and recommended): Download and use NSSM. Or use SC to create a service without downloads.

Using SC to create a service from command line

The SC command communicates with the Windows Service Controller and installed services. When used with its create command option, you can use it to create a Windows service under which your binary will run. But the binary must be created for this (so Windows knows it will respect API calls and gives correct status information).

The SC Create command uses the following format:

sc create serviceName binpath="path\to\java.exe path\to\.jar" optionName= optionValue...

where:

  • create is the command to be run by SC (this command name is mandatory to create a service).
  • serviceName is the name of the Windows service to be created. This is the name given to the service key in the registry. Note that this name is different from the display name.
  • binpath is the (mandatory) parameter that specifies the path to the Win32/x64 binary. Note that a space must be used between the binpath parameter and its argument. You should also use double quotes around the argument.
  • optionName specifies optional parameters, which are described in the documentation

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .