Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Exiting' (ctrl+c) a process from console - Eclipse vs Intellij

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.

like image 578
pdeva Avatar asked May 15 '09 12:05

pdeva


People also ask

What is the difference between IntelliJ and Eclipse?

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.

How do I close the console in Eclipse?

Close Console and reopen - Window -> Show View -> Console. Brute force method - Restart Eclipse. If above doesn't work for you try this.

How is IntelliJ better than Eclipse?

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.


2 Answers

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

like image 123
mki Avatar answered Sep 23 '22 02:09

mki


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.

like image 37
Alex Florescu Avatar answered Sep 23 '22 02:09

Alex Florescu