Java Process is not getting killed when its Windows service is stopped

Sarika Singh 1 Reputation point
2022-06-15T02:47:30.93+00:00

Hi,

I have created a Windows Service for a Java based application which is deployed in Tomcat in a Windows 10 machine using below article:

Ref: https://learn.microsoft.com/en-us/troubleshoot/windows-client/deployment/create-user-defined-service

Command I used to create a Windows service is
"C:\Program Files (x86)\Windows Resource Kits\Tools\Instsrv.exe" apache "C:\Program Files (x86)\Windows Resource Kits\Tools\Srvany.exe"

I did required registry configuration changes also for this windows service.

But when I stopped this service then that Java process in Task Manager is not getting killed and even if service is stopped, application keeps running.

Can you please help on this issue that why Java process is not getting killed?

Thanks,
Sarika Singh

Windows for business Windows Server User experience Other
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. EckiS 916 Reputation points
    2022-06-17T13:53:33.017+00:00

    when you are calling a batch file to start the Java process, this will not work:
    Q&A: Why doesn’t Srvany Close my Application when I Stop the Service?

    0 comments No comments

  2. MotoX80 36,291 Reputation points
    2022-06-17T14:03:59.867+00:00

    Use NSSM instead of srvany.

    https://nssm.cc/

    It will terminate the launched process when you stop the service.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.