It seems that in Eclipse, if you want to send ctrl+c to a process you cant. The terminate button on the console just kills the running process without running the shutdown hooks. I know that java itself doesnt allow sending a signal to another process.
However it seems that intellij idea does have a 'exit' button next to its 'stop' button which does allow shutdown hooks to run.
Can somebody tell me how intellij does this?
I need to send ctrl+c from my program to another java process too.
The main difference between Eclipse and IntelliJ lies in their intended use. While IntelliJ is a Java IDE for professionals and students, Eclipse focuses on open-source development with its wide range of optimized IDEs. Compared to IntelliJ IDEA, Eclipse comes in 40+ languages.
Close Console and reopen - Window -> Show View -> Console. Brute force method - Restart Eclipse. If above doesn't work for you try this.
IntelliJ is much easier to use as compared to Eclipse. The learning curve is far faster in IntelliJ, which makes developing easier and more natural. Code completion, Dropdowns, quick view, project wizards, etc. are all possible in both Eclipse and IntelliJ, but the user experience in IntelliJ is much more satisfying.
Intellij use a native library to send a signal on Windows and the command kill on Unix.
Here is a source code
Has you said you can't send a signal in Java. So you need to execute native code.
Look at the question here
It is my understanding that this happens only on Windows with Eclipse. Also see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=38016
As far as just testing your hooks you can do it by calling System.exit() and then I suppose your users will not run the application using Eclipse so it's ok to count on it working for them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With