使用 Ant 构建 JavaFX 应用程序

Build JavaFX app using ant

我一直在寻找解决我的问题的方法,我没有找到任何可以帮助我的东西,我需要从我的应用程序创建 exe,当我编译它时它工作,但是当我尝试生成exe 它给我一个例外:

Caused by: java.lang.IllegalStateException: Location is not set.
        at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
        at javafx.fxml.FXMLLoader.load(Unknown Source)
        at br.nivelamento.MainApp.initRootLayout(Unknown Source)
        at br.nivelamento.MainApp.start(Unknown Source)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication13
(Unknown Source)

build.xml

<project name="Nivelamento" default="do-deploy" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
    <target name="init-fx-tasks">
        <path id="fxant">
            <filelist>
                <file name="${java.home}\..\lib\ant-javafx.jar" />
                <file name="${java.home}\lib\jfxrt.jar" />
            </filelist>
        </path>

        <taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpathref="fxant" />
    </target>
<fx:resources id="appRes">
            <fx:fileset dir="dist" includes="Nivelamento.jar" />
            <fx:fileset dir="dist" includes="libs/*" />
        </fx:resources>

MainApp.class

package br.nivelamento;

public class MainApp extends Application {

    private Stage primaryStage;
    private BorderPane rootLayout;

    @Override
    public void start(Stage primaryStage) {
        this.primaryStage = primaryStage;
        this.primaryStage.setTitle("NivelamentoApp");
        setUserAgentStylesheet(STYLESHEET_CASPIAN);
        initRootLayout();
    }

    public static void main(String[] args){
        MainApp.launch(MainApp.class, args);
    }
    public void initRootLayout() {
        try {
            // Carrega o root layout do arquivo fxml.
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(getClass().getResource("view/RootLayout.fxml"));
            rootLayout = (BorderPane) loader.load();

            // Mostra a scene (cena) contendo o root layout.
            Scene scene = new Scene(rootLayout);
            primaryStage.setScene(scene);

            // Dá ao controller o acesso ao main app.
            RootLayoutController controller = loader.getController();
            controller.setMainApp(this);

            //liga o hibernate
            JpaUtil.getEntityManager();

            primaryStage.show();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Folders Tree

谁能帮帮我? 谢谢

经过多次尝试终于成功了,错误在 loader.setLocation (MainApp.class.getResource ("view / RootLayout.fxml")); RootLayout.fxml 看到不是真名真名是rootLayout.fxml 修复大写字符就解决了我的问题