1

I have to start, stop a jar in a flow 1. I have to stop it if it is already running and then start 2. All this is being worked in Udeploy. 3. I'm installing the jar using the below command. java -jar jarname.jar

When I use sc query servicename, it says the service is not installed as a Windows service. So, I can check, stop and start if it is only a windows service.

How can I install this as a windows service with a servicename to identify ?

Pbr_Prajwal
  • 46
  • 1
  • 3
  • Does this help: http://stackoverflow.com/questions/7687159/how-to-convert-a-java-program-to-daemon-with-jsvc Apache Commons Daemon can "daemonize" any Java program. On Windows it will create a Service. There are alternatives, for example Tanuki – Marged Nov 10 '15 at 10:09

1 Answers1

0

You can use nssm to install a jar as a Windows service. No installation of nssm is needed. Just place it somewhere on the system (preferably somewhere in your PATH) and run it.

Here is the command to execute as a batch:

nssm.exe install "(service-name)" "{java.exe path from jre}" "-jar {jar-name-absolute-path}"

nssm.exe set "{service-name}" AppDirectory "{jar-path}"

Devesh
  • 856
  • 5
  • 15