I tried to install a java program using prunsrv. The environment is Windows 2008 R2 64 bit, the jar file was complied with Java 1.8 64 bit. The result service registry entry was also attached.
The Java class source is similar to this:
package prcrun;
public class TestMain {
private static boolean stop = false;
private static int i = 0;
public static void start() {
while (!stop) {
System.out.println("Started: " + i++);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void stop() {
stop = true;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
start();
}
}
Prunsrv script:
set SERVICE_NAME=PcrunTest
set PR_INSTALL=C:\prcrun\amd64\prunsrv.exe
REM Service log configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=c:\test
set PR_STDOUTPUT=c:\test\stdout.txt
set PR_STDERROR=c:\test\stderr.txt
set PR_LOGLEVEL=Error
REM Path to java installation
set PR_JVM=C:\java\bin\server\jvm.dll
set PR_CLASSPATH=pcruntest.jar
REM Startup configuration
set PR_STARTUP=auto
set PR_STARTMODE=jvm
set PR_STARTCLASS=prcrun.TestMain
set PR_STARTMETHOD=start
REM Shutdown configuration
set PR_STOPMODE=jvm
set PR_STOPCLASS=prcrun.TestMain
set PR_STOPMETHOD=stop
C:\prcrun\amd64\prunsrv.exe //IS//%SERVICE_NAME%
Got the following error when I tried to start the service: Windows could not start the service on Win2008. Error:1067: The process terminated unexpectedly.
Please advice what did I do wrong on this.
Thanks a lot!