Error loading fxml files from a folder other than the bin folder

后端 未结 3 898
天命终不由人
天命终不由人 2020-12-06 23:14

I am a fairly new java programmer. I only have about five weeks of experience, starting from zero, and I am having problems getting javafx fxml files created in Scene Builde

相关标签:
3条回答
  • 2020-12-06 23:23

    I was having the same problem. Looked inside my Jar (with Winzip) and see that the FXML file isn't there. Turns out my ANT script building the jar files was only including the *.class files from the bin directory of my project.

    0 讨论(0)
  • 2020-12-06 23:24

    Both exceptions say "the (FXML) file you are trying to load cannot be found in the location you have provided". Your filename is wrong or its path. Give your package structure or at least the path of class file that includes load(String pFileName, Stage pStage, String pTitle) method and the path of FXML file you want to load. Read the javadoc API of getResource() and examine sample codes about it on the net.

    0 讨论(0)
  • 2020-12-06 23:30

    It's a path issue, java needs to know where to get the file from the package hierarchy. So using "/package1/resourcename.fxml" should find the source from the root of the tree. You normally leave off the "/" at the start as you are already at the top of the package tree.

    0 讨论(0)
提交回复
热议问题