0

我正在从 Java 8(Oracle JDK)切换到 OpenJDK 11 和 OpenJFX 11。我已经成功地让我的项目通过 Maven 通过clean javafx:run命令在 Eclipse 中工作,maven-compiler-plugin但是我在构建可运行的 jar 和 windows 可执行文件时遇到了问题。我不需要可运行的 linux 或 mac,因为这个项目只是一个内部产品,我们只使用 windows。

我已经尝试了几个插件,例如maven-shade-plugin,也尝试运行mvm package无济于事。我已经尝试过这个Build executable JAR with JavaFX11 from maven和这个How to deploy a JavaFX 11 Desktop application with a JRE

过去我可以通过 Eclipse 的“Export Runnable Jar”选项构建一个可执行 jar,然后通过 launch4j 创建一个可执行文件,但这似乎不再起作用,我理解这可能是由于 OpenJDk 9+ 的模块化结构。

我添加了所有 JavaFX 依赖项以及我需要的 JAXB 依赖项,并且在构建它时它在 IDE 中运行(尽管一旦我让它在 Maven Run 中运行,我就无法让它作为 Java 应用程序运行配置运行配置。

这是我的插件:

<plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.3</version>
                <configuration>
                    <mainClass>com.tapestry.testertools.ApplicationMainFrame</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.tapestry.testertools.ApplicationMainFrame</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                 </executions>
            </plugin>
        </plugins>

这是我尝试运行时的错误消息mvn clean package

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.325 s
[INFO] Finished at: 2019-09-20T09:19:35-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project testertools: Fatal error compiling: invalid flag: --module-path -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
4

0 回答 0