I have a simple console application which sometimes need to perform graphics operations, for those I\'m using JavaFx framework (there are some functions that I need like the
I was able to fix this problem by calling com.sun.javafx.application.PlatformImpl.tkExit()
immediately before Platform.exit()
. I don't really understand the JavaFX source that well, but it seems to be working; YMMV.
Update: Doing this in Java 8 will produce a warning, you can just turn the warning off with @SuppressWarnings("restriction")
. It shouldn't be a problem.
I figured this out by digging through the source code; JFXPanel
has this little snippet (this is from JavaFX 2.2.25)
finishListener = new PlatformImpl.FinishListener() {
public void idle(boolean paramAnonymousBoolean) {
if (!JFXPanel.firstPanelShown) {
return;
}
PlatformImpl.removeListener(JFXPanel.finishListener);
JFXPanel.access$102(null);
if (paramAnonymousBoolean)
Platform.exit();
}
public void exitCalled()
{
}
The problem is, if you are using only a little bit of JavaFX in your application, then the idle(boolean)
method never does anything (because firstPanelShown == false
), which prevents the listener from getting removed, which prevents the JavaFX Toolkit
from shutting down... which means you have to shut it down manually.