Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaFX.FXML.LoadException

raulzinho17Dec 29 2016 — edited Jan 9 2017

I am having an issue with loading a .fxml file to be the graphics of an application I am creating.  While I am in the Java IDE the program runs fine, but when I compile it and run it elsewhere, it gives me the LoadException error.  Could someone help me figure out what the issue is? Any help would be greatly appreciated.

Controller with error:

package application;

import java.io.*;

import java.net.*;

import java.util.*;

import javafx.collections.*;

import javafx.event.*;

import javafx.fxml.*;

import javafx.scene.*;

import javafx.scene.control.*;

import javafx.scene.image.*;

import javafx.scene.input.*;

import javafx.stage.*;

public class LoginController implements Initializable {

    @FXML private Button login;

 

    @FXML private TextField txtPassword;

    @FXML private TextField txtUsername;

 

    @FXML private Label lblStatus;

    @FXML private Label lblSignup;

 

    @FXML private CheckBox cursorCheckbox;

    @FXML private CheckBox musicCheckbox;

 

    @FXML private ComboBox<String> resolutionBox;

 

    @FXML private ObservableList<String> list = FXCollections.observableArrayList("800x600");

 

    private boolean userPass;

    public String username;

    private File file;

    private String resolution = "n";

    private Parent root;

    public void Login(ActionEvent event) throws Exception {

        BufferedReader br = null;

        try {

            file = new File("stats/userInformation.txt");

            if (!file.exists()) {

                lblStatus.setText("Invalid Credentials...");

            } else {

                   br = new BufferedReader(new FileReader("stats/userInformation.txt"));

                String line;

             

                while ((line = br.readLine()) != null) {

  

                    if (txtUsername.getText().equals(line) && txtPassword.getText().equals(br.readLine())) {

                        br.close();

                        if (resolution.equals("n")) {

                            lblStatus.setText("No Resolution Chosen");

                            userPass = false;

                            break;

                        }

                        file = new File("stats/currentUser.txt");

                        if (!file.exists()) {

                            file.createNewFile();

                        }

                        PrintWriter pw = new PrintWriter(new FileWriter(file));

                        pw.println(txtUsername.getText());

                        pw.println(resolution);

                        pw.close();

                        userPass = true;

                        break;

                    } else {

                        userPass = false;

                        lblStatus.setText("Invalid Credentials...");

                    }

                }

                 

                if (userPass) {

                    lblStatus.setText("Login Successful!");

                    Stage primaryStage = new Stage();

                    if (resolution.equals("800x600") {     // <<<<< I tested it with and without this if statement and it was not affected.

                         root = FXMLLoader.load(getClass().getResource("/application/Main800x600.fxml"));   // <<<<<<< Issue is right here...

                    }

                    Scene scene = new Scene(root);

                    scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());

                    primaryStage.setScene(scene);

                    primaryStage.setTitle("Darkness Overhaul™");

                    primaryStage.getIcons().add(new Image("/img/battleCursor.png"));

                    scene.setCursor(Cursor.NONE);

                    primaryStage.show();

                    Stage stage = (Stage) login.getScene().getWindow();

                    stage.close();

                }

            }

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

 

    public void Signup(MouseEvent event) throws Exception {

        Stage primaryStage = new Stage();

        root = FXMLLoader.load(getClass().getResource("/application/Signup.fxml"));

        Scene scene = new Scene(root);

        scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());

        primaryStage.setScene(scene);

        primaryStage.setTitle("Darkness Overhaul™");

        primaryStage.getIcons().add(new Image("/img/battleCursor.png"));

        Image img = new Image("/img/cursor.png");

        scene.setCursor(new ImageCursor(img));

        primaryStage.show();

        Stage stage = (Stage) lblSignup.getScene().getWindow();

        stage.close();

    }

    @Override

    public void initialize(URL location, ResourceBundle resources) {

        resolutionBox.setItems(list);

    }

 

    public void resolutionChanged(ActionEvent event) {

        resolution = resolutionBox.getValue();

    }

}

Error: (It's limited because it doesn't occur while in the IDE, so I can't get the full error)

javafx.fxml.LoadException:

file:/C:/Users/raulr/Desktop/Darkness%20Overhaul/Darkness%20Overhaul.jar!/application/Main800x600.fxml:94

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 6 2017
Added on Dec 29 2016
1 comment
2,577 views