Error when trying to run an executable .jar as a Windows service using NSSM

aneela picture aneela · Oct 23, 2014 · Viewed 7.4k times · Source

I got an executable .jar file which I want to run as a Window service to keep it executing even if I get logged out. I searched and found NSSM. However, after completing configuration, when I started service, it stopped and printed Unexpected status SERVICE-STOPPED in response to start control. I have just added my path and startup directory in the Application tab, nothing else. Moreover, I am unable to find any log file nssm may create to check what actually has happened.

Answer

Charissa Willard picture Charissa Willard · Aug 13, 2015

NSSM logs messages to the Windows System Event Log. To bring up the Event Viewer, just enter 'event viewer' in the Windows Start menu. Once in the Event Viewer, select Event Viewer (Local)->Windows Logs->Application->nssm or Event Viewer (Local)->Custom Views->Errors & Warnings View.

In addition, make sure you configure log files for stdout and stderr when installing your service using NSSM.

Your NSSM properties for installing an executable jar file should look something like this:

Path: C:\Program Files (x86)\Java\jdk1.7.0_45\bin\javaw.exe
Startup directory: C:\Program Files (x86)\Jars
Arguments: -jar C:\Program Files (x86)\Jars\my_executable.jar