2

I'm using IntelliJ IDEA and wrote a very basic JavaFX program (or really just started to write the program). When I run the program to check my GUI, then hit the X button to close the java window I get the following. If I code a button to say Platform.exit() it also gives me this code:

Process finished with exit code -1073741819 (0xC0000005)

I coded a button to call System.exit(0) and when I click it, it prints to the console that the exit button was clicked then says:

The Java SE Binary has stopped working.

I started up a fresh JavaFX project in Intellij IDEA and hit run to check the basic sample window it runs and that also exits with the exit code listed above.

I have the latest JDK installed (jdk1.8.0_121 64 bit), the latest version of scenebuilder from GluonHQ, and am running Windows 10 Pro x64.

Not sure what else to provide info wise, please let me know if you need more information.

Exit Button's code (fxid is the same in controller/.xml file). I plan to do a lambda in the future, still wrapping my head around those, but this should work as is, no?

exitButton.setOnAction(new EventHandler<ActionEvent>()
    {
        @Override
        public void handle(ActionEvent event)
        {
            System.out.println("You clicked exit!");
            Platform.exit();
        }
    });

EDIT: This is the code that by itself is just the sample project IntelliJ IDEA creates when you start a new JavaFX project. With no tweaks at all I still get that exit code instead of 0 as expected, so something is happening independent of the code I wrote.

On sample.fxml

<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<GridPane fx:controller="sample.Controller"
          xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>

on Controller.java

package sample;

public class Controller {
}

on Main.java

package sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(root, 300, 275));
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
TomH
  • 117
  • 1
  • 11
  • Could you post more relevant code? I'm wondering if some stream object might need to be closed - something like that. – Adrian M. Feb 07 '17 at 18:36
  • What do you want to achieve , by calling `Platform.exit();`. Is there any custom implementation in your `Application`'s stop method? If you want to completely shut down the JVM , call `System.exit(0);` instead – AntJavaDev Feb 07 '17 at 18:50
  • 1
    @AdrianM. I put more code in my original post. I did try... Platform.exit(); System.exit(0); Adding System.exit(0) causes the SE Binary to crash. – TomH Feb 07 '17 at 19:49
  • @AntJavaDev see above comment, also adding more code to original post, thank you for your help – TomH Feb 07 '17 at 19:50

2 Answers2

2

According to various sources, it seems that this was an issue with a range of NVidia drivers. I was getting return code 0xC0000005, updated my drivers to 378.66 (released 02/13/2017, current as of 2/21/2017) and stopped getting this issue.

CAD97
  • 1,160
  • 12
  • 29
0

Try properly closing the GUI window before terminating the entire program:

exitButton.setOnAction(new EventHandler<ActionEvent>()
{
    @Override
    public void handle(ActionEvent event)
    {
        event.getSource().getScene().getWindow().close();
        System.out.println("You clicked exit!");
        System.exit(0);
    }
});

as seen here: https://stackoverflow.com/a/41838183/4084636

Community
  • 1
  • 1
Adrian M.
  • 360
  • 7
  • 17
  • unfortunately that doesn't work. As shown in my original post, if I do that I get a Java SE Binary crash. I coded a button to call System.exit(0) and when I click it, it prints to the console that the exit button was clicked then says: The Java SE Binary has stopped working. – TomH Feb 08 '17 at 02:12