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 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
5,942 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
8,174 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. EckiS 806 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?

    No comments

  2. MotoX80 23,491 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.