0

I want to create a windows service with the following command line:

java -jar C:\server\server.jar -conf C:\conf\default.json

I tried something like this: sc create ServerService binPath= "java -jar C:\server\server.jar -conf C:\conf\default.json" DisplayName= "server Service" start= auto

and trying to start my previous created service, an error that the server doesn't start in time request ...

I saw that a windows service must start in a max time before considered timeout.

Is normal because the java command line start a server which never finish because the java process of the server must remains and listening incoming request.

I understood (but my comprehension can be it can be false), I must try to launch the command line and return directly the result in order to the service is considered started. Consequently I tried this:

sc create ServerService binPath= "cmd /c start java -jar C:\server\server.jar -conf C:\conf\default.json" DisplayName= "server Service" start= auto

but always the same error occurred ... do you have a idea how I can do that plz ?

thank a lot and best regards

a windows service which can be start without error and my server up

tictac
  • 1
  • Applications that are Windows Services need to implement specific APIs to act as a service. It's possible to use one of many Win Services wrapper applications or you can implement the service control callbacks / API in Java with + Foreign Memory API (incubating or preview JDK16-20). [How to create a windows service from java app](https://stackoverflow.com/questions/68113/how-to-create-a-windows-service-from-java-app) – DuncG Jul 28 '23 at 15:47

0 Answers0