I want to start a Minecraft Server as a Service in a Windows Server 2008 R2 machine.
This command line works fine:
c:\Windows\System32\java.exe -cp c:\Data\minecraft-server\minecraft-server.jar com.mojang.minecraft.server.MinecraftServer -Xms512M -X mx512M
The I created a service using the following SC command:
sc config MinecraftServer binPath= "c:\Windows\System32\java.exe -cp c:\Data\minecraft-server\minecraft-server.jar com.mojang.minecraft.server.MinecraftServer -Xms512M -Xmx512M"
The service is created and when I start the service Windows starts it but then it comes back with a message that says:
The service is not responding to the control function.
The service does start but for some reason the command does not let the system know that it is started.
There is something simple that I've missed but I am not very experienced with Java so if anoyone here can give my guidance it would be very welcome!
You can't just run any old EXE as a service. Services need to respond to callbacks from the Service Control Manager, and running a non-service EXE as a service will cause the messages you're seeing.
You can use a tool like NSSM, SRVANY, or any of a number of other service "wrapper" programs to get a non-service EXE to run as a service.
On the Java-specific front the WinRun4J application acts as a replacement for "java.exe" and can be used to start Java programs as services. I've used it when the command-line for a Java program was too long for the Service Control Manager to handle.
Refer to this thread on stackoverflow