I tried
Thread.setDefaultUncaughtExceptionHandler...
in the main, and also in the start(Stage primaryStage) method. It ain’t working.
I also tried
public static void main(String[] args) {
try {
launch(args);
}catch(Throwable t) {
System.out.println(t.getMessage);
}
}
Exception stack trace.
at javafx.concurrent.Task$TaskCallable$2.run(Task.java:1251) at
com.sun.javafx.application.PlatformImpl$3.run(PlatformImpl.java:141)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at
com.sun.glass.ui.gtk.GtkApplication$1$1.run(GtkApplication.java:56)
at java.lang.Thread.run(Thread.java:662)
Thanks for helping.
If you check the code for
Platform.runLater()(see below), you will see that the exceptions are swallowed (lines 146 / 147), so a default uncaught exception handler won’t be able to catch them – based on that piece of code, I don’t think you have any options but to include try/catch blocks in your runnables.Note that this issue has been reported (requires login – registration is free) and should be fixed in Lombard (= Java FX 8.0 to be released with Java 8 next year).
You could alternatively create a utility method and call
Code of
Platform.runLater: