import javafx.application.Application; import javafx.application.Platform; import javafx.stage.Stage; /** * * @author Stanislav Smirnov */ public class ExceptionHandler extends Application { @Override public void start(Stage stage) throws Exception { Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> { System.err.println("Trapped " + throwable); Platform.exit(); }); Platform.runLater(() -> { throw new RuntimeException(); }); } public static void main(String[] args) { launch(args); } }