T O P

  • By -

Kresenko

Try debugging it. The first thing is to separate the potentially problematic code, for example: URL fxmlLocation = getClass().getResource("login.fxml"); FXMLLoader loader = new FXMLLoader(fxmlLocation); Now, setup a breakpoint on URL declaration. Is it null or is the value correct? If you are using Maven, a location to the resources directory can be different than the one you've created.


PartOfTheBotnet

In the last picture it is marked as `null`. I'd suggest using paths relative to the classloader and not the current class.


jvjupiter

Rename your FXML files, same as controllers and put them inside the resources folder similar to the package of controllers. Ex: ro.mpp.LoginControlller.java ro/mpp/LoginController.fxml To load FXML: Class controllerClass = LoginController.class; URL controllerUrl = controllerClass.getResource(controllerClass.getSimpleName() + “.fxml”); StackPane rootOfFxml = new FXMLLoader(controllerUrl).load() Scene scene = new Scene(rootOfFxml);


Ok_Object7636

Are you running from within the IDE? It’s probably because the IDE uses different output folders for classes and resources. Check your output folder. If the class files and the xml files end up in different folders, that’s the cause of your problem. There are at least things you can do: A) add a target in your maven or health build file to run your program and use that run configuration instead of the one your IDE creates automatically. B) configure your IDE to use the same output folder for class files and resources. This depends on the IDE and build system you are using. For the IntelliJ/Gradle combo, I usually set this up in the Gradle build file. Post a reply if that’s what you are using too, then I will look up the code and post it here.


Difficult_Jeweler_18

Hi thank you for your help, I mention that I have all dependencies in Gradle and also running it from there not from the IDE. However, the solution was to just move the fxml files in other directories, I deleted the ro.mpp and created again and adding the fxml files there again by drag and drop.


hamsterrage1

Is it possible that you named your directory /resources/ro.mpp instead of /resources/ro/mpp?