Introduction

Procrun is a set of libraries and applications for making Java applications to run on WIN32 much easier.

Procrun service application

Prunsrv is a service application for running applications as services. It can convert any application to run as a service.

Procrun monitor application

Prunmgr is a GUI application for monitoring and configuring procrun services.

The available command line options are:

//ES// Edit service configuration This is the default operation. It is called if the no option is provided but the executable is renamed to servicenameW.exe
//MS// Monitor service Put the icon in the system try

Command line arguments

Each command line directive is in the form of //XX//ServiceName

The available command line options are:

//TS// Run the service as console application This is the default operation. It is called if the no option is provided but the executable is renamed to servicename.exe
//RS// Run the service Called only from ServiceManager
//SS// Stop the service
//US// Update service parameters
//IS// Install service
//DS// Delete service Stops the service if running

Command line parameters

Each command parameter is prefixed with -- . If the command line is prefixed with ++ then it's value will be appended to the existing option. If the environment variable with the same name as command line parameter but prefixed with PR_ exists it will take precedence. For example:

set PR_CLASSPATH=xx.jar

is equivalent to providing

--Classpath=xx.jar

as command line parameter.

ParameterName Default Description
--Description Service name description (maximum 1024 characters)
--DisplayName ServiceName Service display name
--Install procrun.exe //RS//ServiceName Install image
--Startup manual Service startup mode can be either auto or manual
--Type Service type can be interactive to Allow service to interact with desktop. Use this option only with Local system accounts.
--DependsOn List of services that this service depend on. Dependent services are separated using either # or ; characters
--Environment List of environment variables that will be provided to the service in the form key=value . They are separated using either # or ; characters
--User User account used for running executable. It is used only for StartMode java or exe and enables running applications as service under account without LogonAsService privilege.
--Password Password for user account set by --User parameter
--ServiceUser Specifies the name of the account under which the service should run. Use an account name in the form DomainName\UserName . The service process will be logged on as this user. if the account belongs to the built-in domain, you can specify .\UserName
--ServicePassword Password for user account set by --ServiceUser parameter
--JavaHome JAVA_HOME Set a different JAVA_HOME then defined by JAVA_HOME environment variable
--Jvm auto Use either auto or specify the full path to the jvm.dll . You can use the environment variable expansion here.
--JvmOptions -Xrs List of options in the form of -D or -X that will be passed to the JVM. The options are separated using either # or ; characters. if you need to embed either # or ; character put them inside single quotes.
--Classpath Set the Java classpath
--JvmMs Initial memory pool size in MB
--JvmMx Maximum memory pool size in MB
--JvmSs Thread stack size in KB
--StartImage Executable that will be run.
--StartPath Working path for the start image executable.
--StartClass Class that will be used for startup.
--StartParams List of parameters that will be passed to either StartImage or StartClass. Parameters are separated using either # or ; character.
--StartMethod Main Method name if differs then main
--StartMode executable Can one of jvm java or exe
--StopImage Executable that will be run on Stop service signal.
--StopPath Working path for the stop image executable.
--StopClass Class that will be used on Stop service signal.
--StopParams List of parameters that will be passed to either StopImage or StopClass. Parameters are separated using either # or ; character.
--StopMethod Main Method name if differs then main
--StopMode executable Can one of jvm java or exe
--StopTimeout No Timeout Defines the timeout in seconds that procrun waits for service to exit gracefully.
--LogPath working path Defines the path for logging
--LogPrefix jakarta_service Defines the service log filename
--LogLevel INFO Defines the logging level and can be either error , info , warn or debug
--StdOutput Redirected stdout filename
--StdError Redirected stderr filename

Installing services

To install the service, you need to use the //IS// parameter.

Install the service named 'TestService'prunsrv //IS//TestService --DisplayName="Test Service" \--Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm \--StartClass=org.apache.SomeStartClass --StartParams=arg1;arg2;arg3 \--StopClass=org.apache.SomeStopClass --StopParams=arg1#arg2 \

Updating services

To update the service parameters, you need to use the //US// parameter.

Update the service named 'TestService'prunsrv //US//TestService --Description="Some Dummy Test Service" \--Startup=auto --Classpath=%CLASSPATH%;test.jar

Removing services

To remove the service, you need to use the //DS// parameter. If the service is running it will be stopped and then deleted.

Remove the service named 'TestService'prunsrv //DS//TestService

Debugging services

To run the service in console mode, you need to use the //TS// parameter. The service shutdown can be initiated by pressing CTRL+C or CTRL+BREAK . If you rename the prunsrv.exe to testservice.exe then you can just execute the testservice.exe and this command mode will be executed by default.

Run the service named 'TestService' in console modeprunsrv //TS//TestService [additional arguments]