score:16
The red stop button forcibly kills the application, i.e. not gracefully, so the JVM doesn't know that the application is exiting, therefore the shutdown hooks are not invoked.
Unfortunately, there is no way (in Windows, at least) to provide a mechanism that ensures that the hook is always invoked. It's just something that may be invoked, but there is no guarantee.
score:-1
If you just want to test if the hook is working or not, throw new RuntimeException()
from the trigger point. This should call the shutdown hook even from Eclipse.
score:0
Red stop button just terminates the application and according to eclipse devs they can't do anything about it see this issue in eclipse bug tracker.
score:0
@Pacerier - From the Javadoc: In rare circumstances the virtual machine may abort, that is, stop running without shutting down cleanly. This occurs when the virtual machine is terminated externally, for example with the SIGKILL signal on Unix or the TerminateProcess call on Microsoft Windows. The virtual machine may also abort if a native method goes awry by, for example, corrupting internal data structures or attempting to access nonexistent memory. If the virtual machine aborts then no guarantee can be made about whether or not any shutdown hooks will be run.
score:2
I know I'm a bit late to the party, but I found this thread seeking for help and so will probably others.
We had the same issue and solved it with an Eclipse plugin (on Linux) which provides additional stop buttons now. I hope this serves all of you as well as it did help us :)
score:9
I made a hack by replacing JavaProcess with decorated one:
IProcess p = launch.getProcesses()[0];
launch.addProcess(new JavaProcessDecorator(p));
launch.removeProcess(p);
And decorator is overriding terminate function.
public class JavaProcessDecorator implements IProcess {
private IProcess p;
public JavaProcessDecorator(IProcess p) {
this.p = p;
}
private boolean sigkill = false;
@SuppressWarnings("rawtypes")
@Override public Object getAdapter(Class arg) { return p.getAdapter(arg); }
...
@Override public ILaunch getLaunch() { return p.getLaunch(); }
@Override public IStreamsProxy getStreamsProxy() { return p.getStreamsProxy(); }
@Override public void setAttribute(String s1, String s2) { p.setAttribute(s1, s2); }
@Override public void terminate() throws DebugException {
if(!sigkill) {
try {
IDebugIService cs = DirmiServer.INSTANCE.getRemote("main", IDebugIService.class);
if(cs != null) cs.modelEvent(new TerminateRequest());
} catch (RemoteException e) { }
this.sigkill = true;
} else p.terminate();
}}
At first click on red button, I send a message to application asking for gently termination. If it is not working, second click on red button will kill it.
Source: stackoverflow.com
Related Query
- Shutdown hook doesn't work in Eclipse
- How to get shutdown hook to execute on a process launched from Eclipse
- Terminated Spring Boot App in Eclipse - Shutdown hook not called
- What is the correct way to add a Shutdown Hook for an Eclipse RCP application?
- Java Eclipse JCurses Library doesnt work after hours of triing of fixing it
- Jump to definitions in eclipse doesnt work
- Reading text from website doesnt work (BufferedReader, InputStream) Android, Eclipse
- Eclipse AVD doesnt work
- eclipse Java autocompletion doesnt work
- Playing videos works fine in Eclipse but when exporting the java project as an runnable JAR file it doesnt work anymore
- Eclipse doesnt work after choosing workspace
- Hibernate Entity doesnt work for Oracle PLSQL in Eclipse
- Removing invalid library references from Eclipse Mars doesnt work
- My JAR doesnt work as when launched by eclipse
- XML code doesnt seem to work in JSP code on eclipse browser
- Work on a remote project with Eclipse via SSH
- Eclipse : Maven search dependencies doesn't work
- Cannot make Project Lombok work on Eclipse
- Code assist (ctrl+space) doesn't work on Eclipse Kepler
- Checkstyle Eclipse plugin doesn't work
- How can I get word wrap to work in Eclipse PDT for PHP files?
- How do you setup Eclipse to work on iPhone development (instead of Xcode)?
- Eclipse Run button doesn't work when Android xml file is selected
- What code folding plugins work on Eclipse 3.6?
- Eclipse - Run/Debug shortcut key doesn't work
- Eclipse (C/C++) Error: Job found still running after platform shutdown
- How to cleanly shutdown Eclipse from Linux command line?
- Ctrl+click doesn't work in Eclipse Juno
- Web resources filtering with Maven war plugin does not work in Eclipse with m2e
- eclipse doesn't work with ubuntu 16.04
More Query from same tag
- Compile complex Java program in Ubuntu terminal
- How do I get my text file to be read in as a command line argument in Eclipse?
- Extract RCP perspective layout back into IDE
- Compile and export in java via Terminal
- Eclipse .classpath in SVN: JRE collision
- java.io.FileNotFoundException: (No such file or directory) when running from eclipse
- Unable to run testng annotations in Eclipse
- Python - variable not defined but I think it is
- Add a restored Java project to Eclipse?
- How to get the list of files open in active eclipse editor window in eclipse?
- how to find file (Open Type) by project in eclipse
- Resizing the textView according to text set
- ArrayIndexOutOfBoundsExecption on RangeFinder program
- How to fix "Test source folder in project must have an output folder that is not also used for main resources"?
- How to fix position of layout in a view in eclipse
- Start Tomcat embedded server using Maven [Servlet app] from cmd?
- Multiple java versions installed and java was started but returned exit code=13
- Dynamic amount of entries in GUI using java
- How to call a servlet on Glassfish server in Eclipse
- I don't get the concept of Visual Studio Projects and Solutions
- How to load eclipse sdk in my Windows
- How would you access Eclipse JDT index?
- Eclipse debugger - not work suddenly ( waiting for debugger forever)
- is actionscript eclipse plugin still maintained?
- Two package with same name : Eclipse can't resolve import
- Eclipse stuck with Android Library Update at 3%
- How to use Injection Annotation
- Changing required Java version for Eclipse
- Eclipse and Android with Maven: Unable to instantiate activity ComponentInfo with java.lang.ClassNotFoundException
- How to transplant eclipse 2 maven