Skip to content
Advertisement

How netbeans stops a run?

I’m programming with Java in Linux using Netbeans 7 and as my program (sometimes) could not exit (not in this eon, maybe) I create a thread to handle shutdown

JavaScript

But when I launch the code with netbeans (F6) and stop it through the “STOP” button the thread is not created; but if I run the program through the terminal and send CTRL-c the thread is created.
The question is: what type of signal netbeans launches to terminate the program?
Or (better): how can i handle the stop of netbeans such that the thread is created if i force to stop the program?
Or is there a way to modify how the stop works?

Thank you!

Advertisement

Answer

You are on Linux and this makes it really easy. I have written very little test and observe the same behavior as you – with crtl+c running from the terminal hook is working, stopping in Netbeans it does not. Here are some workarounds:

  1. I’m on Gnome and when I find the running process in the System Monitor and press “End process” on it – hook is working.
  2. Other, more universal way:

    JavaScript

Or in one line:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement