我试图创建、编译我的应用程序并创建一个可执行文件。就目前而言,我看到最好的工具是plugin。
我无法让它工作,所以我开始使用一个基本代码,根据这个代码创建一个项目时生成的代码。
https://www.youtube.com/watch?v=4vd-RE0X5Lg
https://openjfx.io/openjfx-docs/#maven
基本示例可以工作,但当我尝试在代码中使用相同的结构时,或者简单地向代码中添加包含jfoenix的代码。它不能跑。
下面一行似乎是错误的重要行,
导致: java.lang.IllegalAccessError:类com.jfoenix.skins.JFXSpinnerSkin (在模块com.jfoenix中)无法访问类com.sun.javafx.scene.NodeHelper (在模块javafx.graphics中),因为模块javafx.graphics没有将com.sun.javafx.scene导出到模块com.jfoenix
我怎么才能解决这个问题?
到目前为止这是我的pom。
<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>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>9.0.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
<compilerArgs>
<arg>--add-opens</arg><arg>javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>org.openjfx.App</mainClass>
<options>
<option>--add-opens</option>
<option>javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED</option>
</options>
</configuration>
</plugin>
</plugins>
</build>
</project>
发布于 2020-04-28 06:14:02
基于您共享的代码:https://github.com/Ealuthwala/javafx-export
我编辑了POM并使其运行,这就是我看到的输出
我正在分享下面的POM,只需使用这个POM,它就可以工作了。
除此之外,您还必须使用JDK11.0.2或更低版本。您需要更改IDE的设置,以获取此项目的JDK11.0.2或更低版本。
因为您使用的是JFoenix的特性,它不能使用更高版本的JDK。原因在这里解释:https://github.com/jfoenixadmin/JFoenix/issues/955
这样,您就可以使用GluonVM、桌面、Linux、Mac和web (使用JPro)和rasberry饼等在移动(64位android和GluonVM)上运行这段代码。因此,实际上,除非您有非常大的理由想要升级到Jdk 12,否则实际上您不会有任何问题。如果您给出时间,可能需要一年时间,我相信JFoenix团队会修复它,如果它没有完成,而且您真的发现JFoenix非常有用,您可以选择使用这些补丁,或者使用其他的东西。
<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>
https://stackoverflow.com/questions/61471051
复制相似问题