How to shutdown java application correctly from C# one

I have java application which shutdowns correctly when i use CTRL-C, java application saves all data before shutdown. Now i trying to shutdown this java application from my C# console application using Process.Close(), but application dont't save any data when i use this, i also tried Process.CloseMainWindow() but using this nothing is happening, and also Process.Kill() but using this process just killed, without any savining.

How can i raise shutdown hook on java application from C# console application?

Answers


A shutdown hook cannot be raised by another app.

The shutdown hook runs when:

  • A program exists normally. For example, System.exit() is called, or the last non-daemon thread exits.
  • the Virtual Machine is terminated. e.g. CTRL-C. This corresponds to kill -SIGTERM pid or kill -15 pid on Unix systems.

The shutdown hook will not run when:

  • the Virtual Machine aborts
  • A SIGKILL signal is sent to the Virtual Machine process on Unix systems. e.g. kill -SIGKILL pid or kill -9 pid
  • A TerminateProcess call is sent to the process on Windows systems.

Need Your Help

Call getMethod with a subclass as method argument

java reflection subclass invoke superclass

Is it possible to invoke a method where the argument object or the argument class is a subclass and the method himself took the superclass as argument?