I have converted a java executable jar to a Windows executable using Launch4j. I have installed it and a jre to a Windows 8 box, in the c:\program files (x86)\mycomany directory, and executed the following as administrator in a bat file (in order to use prunsvc to run the application as a service):
rem determine the full path to this bat file
set thispath=%~dp0
set SERVICE_NAME=MyService
set PR_INSTALL=%thispath%prunsrv.exe
REM set service stdout and stderr
set PR_LOGPATH=%thispath%
set PR_STDOUTPUT=%thispath%stdout.txt
set PR_STDERROR=%thispath%stderr.txt
set PR_LOGLEVEL=Error
REM path to java
set PR_JVM="%thispath%jre1.8.0_45\bin\client\jvm.dll"
set PR_CLASSPATH="%thispath%jre1.8.0_45\bin\MyService.exe"
REM Startup configuration
set PR_STARTUP=auto
set PR_STARTMODE=jvm
set PR_STARTCLASS=com.mycompany.mainclass
set PR_STARTMETHOD=start
REM Shutdown configuration
set PR_STOPMODE=jvm
set PR_STOPCLASS=com.mycompany.mainclass
set PR_STOPMETHOD=stop
REM JVM configuration
set PR_JVMMS=256
set PR_JVMMX=1024
set PR_JVMSS=4000
set PR_JVMOPTIONS=-Duser.language=EN;-Duser.region=en
set PR_DESCRIPTION="My Service Description"
"%PR_INSTALL%" install %SERVICE_NAME%
The service appears to install successfully; however when I do:
prunsrv.exe start myservice
at the command line as administrator, nothing happens. Instead I see the following in the Windows event log:
The MyService service terminated with the following service-specific error: Incorrect function.