Reputation: 324
I have created a JavaFX application, and noticed that after I close the main stage, the following happens:
I do not create any threads (explicitly not, at least). The threads that are running at this point are (from the debug console):
Which of these threads can stop the JVM from closing? I would think that all of these should be daemon threads...
Here is my Application code:
public class MainApp extends Application {
@Override
public void start(Stage stage) throws Exception {
final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/Main.fxml"));
Parent root = fxmlLoader.load();
Scene scene = new Scene(root);
scene.getStylesheets().add("/styles/Styles.css");
//... Scene/stage setup here
stage.show();
}
@Override
public void stop() throws Exception {
super.stop();
}
public static void main(String[] args) {
launch(args);
}
}
Adding a System.exit(0); on the end of the stop() method fixes this, but I'm not sure if this is the best solution to the problem... Any ideas?
Thx in advance
Upvotes: 1
Views: 266
Reputation: 19431
You say you are using a HSQLDB, you don't show the code where you initialize it. In your stop() method, close that connection.
Upvotes: 1