Last modified: 04 December 2024
Running as a Windows service
There are varieties of commercial and open source solutions allowing Java applications to run as a Windows service. The distribution includes a configuration for a popular open source solution (WinRun4J) as an example of how running the pdrLoader as a Windows service can be achieved. Participants can adapt this example to software of their own choice.
The distribution includes the following files relevant to running as a Windows service:
- pdrServiceInstall.bat installs a Java application as a Windows service.
- pdrServiceUninstall.bat removes a Java application running as a Windows service.
- WinRun4J.exe is a Windows wrapper for the Java run time environment required to run the pdrLoader under a 32-bit JRE environment.
- WinRun4J64.exe is a Windows wrapper for the Java run time environment required to run the pdrLoader under a 64-bit JRE environment.
- WinRun4J.ini is a file containing the configuration data defining the setup of the Windows service.
Installation
Follow the instructions below to install the pdrLoader as a Windows service (assuming Java is installed appropriately):
- Edit the pdrServiceInstall.bat file to update the HOME and JRE environment variables to suit your environment, ensuring the path to the JRE .DLL is valid (such as, %JRE%\bin\server\jvm.dll).
- Configure the HOME environment variable in the pdrServiceUninstall.bat file.
- From the command line in the /lib directory, run the pdrServiceInstall.bat file supplying the following input parameters:
Parameter 1: The name of the Windows service to identify this instance
The following parameter combinations are valid:
pdrServiceInstall.bat pdrLoader
You may need to run this command at elevated privilege levels (Administrative) when the windows service is established in a “Local System” context.
Installation errors
During installation, error messages indicate oversights, with actions as follows for the more common circumstances:
Message |
Actions |
---|---|
The LoadLibrary function failed for the following reason: The specified module could not be found. |
Check the install of the JVM has put the jvm.dll as specified in the JRE environment variable in the pdrServiceInstall.bat file. |
Could not load the Java Virtual Machine. |
Check the install of the JVM has put the jvm.dll as specified in the JRE environment variable in the pdrServiceInstall.bat file. |
Uninstalling
The procedure for uninstalling the pdrLoader as a Windows service is:
- From the command line in the lib directory, run the pdrServiceUninstall.bat file supplying the name of the Windows service as a parameter. The name of the Windows service is identified by the name supplied in the install procedure.
The following parameter combinations are valid:
pdrServiceUninstall.bat pdrLoader