1

I have recently installed the new Java 8u5 update so I can use lambda operations and the new Scene Builder, however I immediately had problems loading the FXML documents. Before I did it in a different thread and used Platform.runLater(...) to load using the FXMLLoader. However this did not work so I put it on the JavaFX application thread like this:

ready.addListener((ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> {
        if (Boolean.TRUE.equals(t1)) {
            Platform.runLater(() -> {
                try {
                    //skipped loading the other FXML documents for this post...
                    final FXMLLoader load = new FXMLLoader(guiResource);
                    final GUIController guiController = new GUIController();
                    load.setController(guiController);
                    scene = new Scene((AnchorPane) load.load());
                    stage.setScene(scene);
                } catch (IOException ex) {
                    Util.err(ex.getLocalizedMessage());
                }
                stage.show();
            });
        }
}

However I am still getting this rather unhelpful post in the netbeans console:

file:/C:/Users/Blah/path/to/my/Application.jar!/resources/GUI2.fxml

That is all it says. Has anyone else had this problem? What does this mean? Why is there an exclamation mark after the .jar?

I thought the problem might have something to do with my variable declarations in the controller so here is an example:

@FXML
Region fileImportVeil;
@FXML
ProgressIndicator fileImportProgressIndicator;

Am I mean to put private in front of all of my FXML fields?

Cobbles
  • 1,748
  • 17
  • 33
  • 1
    You don't need to put `private` in front of it. If you use nothing (package-private), private or protected variables, you need the `@FXML` annotation, for public variables you do not need so. The `.jar!` means that the resource is *inside* the JAR. You need to provide more data to be able to help, start with the stacktrace of the exception. – skiwi Jun 06 '14 at 11:51
  • I don't know where the exception is; all it's giving me is the path of the file, no stacktrace otherwise I would have posted it! – Cobbles Jun 06 '14 at 11:58
  • You are swallowing the stacktrace with `Util.err(ex.getLocalizedMessage())`, you hence only show the error message. – skiwi Jun 06 '14 at 12:07
  • This question is not off topic, I have found the solution that I believe could help others if they have had the same issue. So please remove the hold so I can answer it. – Cobbles Jun 07 '14 at 10:02

1 Answers1

0

Looking at

file:/C:/Users/Blah/path/to/my/Application.jar!/resources/GUI2.fxml

you need to open the Application.jar with 7zip, WinZip or maybe NetBeans, and check the path

/resources/GUI2.fxml

maybe should be

/GUI2.fxml

Most likely the directory /resources is too much, the source root directory being /src/main/resources or so. (Otherwise it could be a case-sensitivity issue.)

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138