Search code examples
javawindowswindows-serviceswinrun4j

How to run a Java application as Windows service using WinRun4J


I'm trying to run a Java application as a Windows service with WinRun4J.

I copied WinRun4J64c.exe in my application directory and placed the following service.ini file beside:

service.class=org.boris.winrun4j.MainService
service.id=MyAPP
service.name=MyAPP
service.description=some description

classpath.1=./lib/*
classpath.2=WinRun4J.jar

[MainService]
class=play.core.server.NettyServer

But if I start the service with: WinRun4J64c.exe --WinRun4J:RegisterService I get:

Service control dispatcher error: 1063

What is wrong?


Solution

  • I didn't get it working, so my workaround is to use Apache Commons Deamon. I executed the included prunsrv.exe with the following parameters:

    prunsrv.exe install "MeineAnwendung" \
    --Install="C:/pfad/zu/prunsrv.exe" \
    --JvmOptions=-Dpidfile.path=NUL
    --Jvm=auto \
    --Startup=auto \
    --StartMode=jvm \
    --Classpath="c:/irgendwo/anwendung/lib/*;" \
    --StartClass=play.core.server.NettyServer