使用JDK 12和Maven构建的自包含JavaFX 12?

时间:2019-08-06 22:11:40

标签: java maven javafx

JDK 12/11中没有包含很多关于JavaFX的线程,您需要自己安装JavaFX,但是我发现只有这个示例性的模块化安装示例,无需外部下载:

https://github.com/openjfx/samples/tree/master/IDE/IntelliJ/Modular/Maven

这是我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>scheduler</groupId>
<artifactId>shop-solver</artifactId>
<version>1.0.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>

<build>
<plugins>
    <plugin>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>0.0.3</version>
        <configuration>
            <mainClass>scheduler.Main</mainClass>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
            <release>12</release>
        </configuration>
    </plugin>
</plugins>
</build>


<dependencies>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>12</version>
</dependency>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>12</version>
</dependency>
<dependency>
    <groupId>com.jfoenix</groupId>
    <artifactId>jfoenix</artifactId>
    <version>9.0.8</version>
</dependency>
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>27.1-jre</version>
</dependency>
<dependency>
    <groupId>org.openjdk.jmh</groupId>
    <artifactId>jmh-core</artifactId>
    <version>1.21</version>
</dependency>
<dependency>
    <groupId>org.openjdk.jmh</groupId>
    <artifactId>jmh-generator-annprocess</artifactId>
    <version>1.21</version>
</dependency>
</dependencies>

当我尝试通过javafx:run插件运行时,仍然出现此错误: Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Unrecognized option: --module-path

当我尝试从IntelliJ运行时,出现另一个错误:

Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0xd5599b7) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0xd5599b7

该项目在JDK1.8和JavaFX 2下运行良好,以下是有关升级发生错误的视频:https://puu.sh/E25JW/7ecdca26d7.webm

同样,问题是我试图以模块化方式构建所有这些库,我希望能够发布具有maven依赖关系的存储库,也许还可以发布插件或构建指令,但是不希望有人克隆我的存储库需要在Maven外部外部安装JavaFX。谢谢。

0 个答案:

没有答案