I’m leatning to work with YAJSW for wrapping java apps into windows services. It works fine with starting application but I want to know how to implement logic in the java application so that when I stop a service it would perform that logic inside the java application.
Something like implementing onStart() and onStop() methods in my java application so I can call these when I start or stop a java service.
You can call your onStart() method/logic right inside your main method which is the entry point for your application. In order to implement onStop(), this is how we have done it …
step-1) Create following class …
step-2) Inside the main method …
This will invoke the ShutdownHandler’s run method when your java application terminates. Hope this helps.