【问题标题】:Building an executable JavaFX app with java SDK 11.0.6使用 java SDK 11.0.6 构建可执行的 JavaFX 应用程序
【发布时间】:2020-07-27 07:07:33
【问题描述】:

我有一个使用 Java SDK 1.8 成功构建和运行的 JavaFX 应用程序。我正在尝试将其移至 Java 11,最终目标是使用 Java 14,并且无法创建可运行的 jar。为了尝试理解这个过程,我下载了 javafx helloFX 示例,并尝试按照 https://openjfx.io/openjfx-docs/#modular 的 Maven 说明进行操作。当我运行 mvn clean javafx:jlink 时出现错误:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< org.openjfx:hellofx >-------------------------
[INFO] Building demo 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hellofx ---
[INFO] Deleting C:\Users\jungl\eclipse-workspace\helloFX\Maven\hellofx\target
[INFO]
[INFO] --- javafx-maven-plugin:0.0.3:jlink (default-cli) @ hellofx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\jungl\eclipse-workspace\helloFX\Maven\hellofx\src\main\resources
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\jungl\eclipse-workspace\helloFX\Maven\hellofx\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.345 s
[INFO] Finished at: 2020-04-14T14:52:18+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.3:jlink (default-cli) on project hellofx: Error: jlink requires a module descriptor -> [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

pom.xml 是

<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>hellofx</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>demo</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>11</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>0.0.3</version>
        <configuration>
          <mainClass>HelloFX</mainClass>
      <jlinkImageName>hello></jlinkImageName>
      <jlinkZipName>hellozip></jlinkZipName>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
<!-- https://mvnrepository.com/artifact/com.zenjava/javafx-maven-plugin -->

谁能指出我正确的方向,因为我无法理解这个问题。

【问题讨论】:

    标签: java maven javafx-11 jlink


    【解决方案1】:

    提供的示例与教程所述的结构不同。 Maven 版本已在 CommandLine 文件夹下更新。如果您转到:..\CommandLine\Modular\Maven\helloFX 并输入命令 mvn clean javafx:ru​​n, clean javafx:jlink, target\hellofx\bin\launcher,它将按照教程中的说明运行。

    【讨论】:

      猜你喜欢
      • 2021-09-15
      • 2012-10-11
      • 2015-10-02
      • 2012-07-27
      • 1970-01-01
      • 2019-02-07
      • 1970-01-01
      • 2015-05-03
      • 2017-08-10
      相关资源
      最近更新 更多