Running a Jar File as a Windows Service Using NSSM
Prerequisites:
Step 1: Download and Extract NSSM
Step 2: Open Command Prompt as Administrator
For example:
cd C:\nssm\win64
Step 3: Install Your JAR File as a Service
nssm install <ServiceName>
2. For example, to install a service named MyJavaApp, you would run:
Recommended by LinkedIn
nssm install MyJavaApp
Step 4: Configure the Service
C:\Program Files\Java\jdk-14.0.1\bin\java.exe
3. Startup Directory: Set this to the directory where your JAR file is located.
4. Arguments: Specify the -jar option followed by the path to your JAR file. For example:
-jar C:\path\to\your\application.jar
Step 5: Start the Service
nssm start MyJavaApp
Conclusion
Using NSSM to run a JAR file as a Windows service is an efficient way to ensure your Java applications start automatically and run reliably in the background. By following the steps outlined in this guide, you can set up, manage, and maintain your Java services with ease. NSSM provides a robust solution with a user-friendly interface, making it a valuable tool for system administrators and developers alike.