How to run a maven java fx project that includes jfoenix using javafx-maven-plugin

后端 未结 1 1521
孤街浪徒
孤街浪徒 2021-01-27 01:14

i was trying to create compile my application and create an executable file. as for now i see the best tool to use is javafx-maven-plugin.

i couldn\'t get it to work, s

相关标签:
1条回答
  • 2021-01-27 01:41

    Based on the code you shared : https://github.com/Ealuthwala/javafx-export

    I edited and the POM so that it runs, and this is the output I see

    I am sharing the POM below, just use this POM and it should work.

    Apart from this you must use JDK 11.0.2 or lower. You need to change settings of your IDE to pick up JDK 11.0.2 or lower for this project.

    Because you are using features of JFoenix which will not work with a higher version of JDK. Reason is explained here : https://github.com/jfoenixadmin/JFoenix/issues/955

    With this you will be able to make this code run on mobile (64-bit android and iPhone ) using GluonVM, and Desktop, Linux, Mac, and web (using JPro), rasberry pie etc. So practically you cannot have any problem with this unless you have a very big reason for wanting to upgrade to Jdk 12. If you give time, may be a year, I am sure JFoenix team will fix it, if it is not done, and you really find JFoenix very useful you can either pitch in and contribute the fixes or use something else.

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.openjfx</groupId>
        <artifactId>test</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>11</maven.compiler.source> <!-- DO NOT USE JDK greater than 11 -->
            <maven.compiler.target>11</maven.compiler.target> <!-- DO NOT USE JDK greater than 11 -->
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-fxml</artifactId>
                <version>11</version>
            </dependency>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-controls</artifactId>
                <version>11</version>
            </dependency>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-graphics</artifactId>
                <version>11</version>
            </dependency>
            <dependency>
                <groupId>com.jfoenix</groupId>
                <artifactId>jfoenix</artifactId>
                <version>9.0.9</version>
            </dependency>
            <dependency>
                <groupId>io.datafx</groupId>
                <artifactId>datafx</artifactId>
                <version>8.0.7</version>
            </dependency>
            <dependency>
                <groupId>io.datafx</groupId>
                <artifactId>flow</artifactId>
                <version>8.0.7</version>
            </dependency>
            <dependency>
                <groupId>org.kordamp.ikonli</groupId>
                <artifactId>ikonli-javafx</artifactId>
                <version>11.4.0</version>
            </dependency>
            <dependency>
                <groupId>org.kordamp.ikonli</groupId>
                <artifactId>ikonli-fontawesome5-pack</artifactId>
                <version>11.4.0</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <!--
            This is what will make the code actually run.
                    This is taken from José Pereda's answer from
                    https://stackoverflow.com/a/56467911/2448015
                -->
                <plugin>
                    <groupId>org.openjfx</groupId>
                    <artifactId>javafx-maven-plugin</artifactId>
                    <version>0.0.4</version>
                    <configuration>
                        <mainClass>org.openjfx.App</mainClass>
                        <options>
                            <option>--add-opens</option><option>javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED</option>
                            <option>--add-opens</option><option>javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED</option>
                            <option>--add-opens</option><option>javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED</option>
                            <option>--add-opens</option><option>javafx.base/com.sun.javafx.binding=ALL-UNNAMED</option>
                            <option>--add-opens</option><option>javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED</option>
                            <option>--add-opens</option><option>javafx.base/com.sun.javafx.event=ALL-UNNAMED</option>
                            <option>--add-exports</option><option>javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED</option>
                            <option>--add-exports</option><option>javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED</option>
                            <option>--add-exports</option><option>javafx.base/com.sun.javafx.binding=ALL-UNNAMED</option>
                            <option>--add-exports</option><option>javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED</option>
                            <option>--add-exports</option><option>javafx.base/com.sun.javafx.event=ALL-UNNAMED</option>
                            <!--
                                Refer : https://github.com/jfoenixadmin/JFoenix/issues/889#issuecomment-450744122
                                In order to make jfoenix works, it should need less and doesn't need all of these.
                                You may have to go one by one to find what - - add-opens ... you'll need in your case.
                                - - add-opens is for enabling deep-reflection
                                - - add-exports is for direct access
                            -->
                        </options>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    
    0 讨论(0)
提交回复
热议问题