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