Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从另一个Jar加载FXML?_Java_Url_Javafx_Fxml - Fatal编程技术网

Java 如何从另一个Jar加载FXML?

Java 如何从另一个Jar加载FXML?,java,url,javafx,fxml,Java,Url,Javafx,Fxml,我有一个依赖项Jar,其中包含一些我想使用的FXML文件,如何引用它 URL location = getClass().getResource("?????????.fxml"); fxmlLoader.setResources(ResourceBundle.getBundle("messages", Locale.getDefault())); fxmlLoader.setLocation(location); fxmlLoader.setBuilderFactory

我有一个依赖项Jar,其中包含一些我想使用的FXML文件,如何引用它

URL location = getClass().getResource("?????????.fxml");
    fxmlLoader.setResources(ResourceBundle.getBundle("messages", Locale.getDefault()));
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());


您是否完全限定了名称(包括包名称)?尝试使用
GetResourceAstream
加载它。
Region root = FXMLLoader.load(getClass().getResource("FILE.fxml"));
final FILEJAVA filejava = new FILEJAVA(stage, root);
BorderPane pane = null;
        try {
            pane = (BorderPane) FXMLLoader.load(FILEJAVA.class.getResource("FILE.fxml"));
            pane.getStyleClass().add("main");
        } catch (IOException ex) {

            Logger.getLogger(FILEJAVA.class.getName()).log(Level.SEVERE, null, ex);
            System.exit(-1);
        }