【问题标题】:maven cannot find javafx 11 when compiling an eclipse applicationmaven在编译eclipse应用程序时找不到javafx 11
【发布时间】:2019-04-13 08:31:01
【问题描述】:

我有一个使用 javafx 11 的 eclipse 应用程序。由于没有更好的解决方案,我在 /opt/javafx-sdk-11.0.2 中安装了 javafx,产品定义包含 --module-path /opt/javafx-sdk-11.0.2/lib/ --add-modules=javafx.controls 作为 vm 参数,并且 .classpath 包含以下几行:

<classpathentry kind="lib" path="/opt/javafx-sdk-11.0.2/lib/javafx.base.jar"/>
<classpathentry kind="lib" path="/opt/javafx-sdk-11.0.2/lib/javafx.controls.jar"/>
<classpathentry kind="lib" path="/opt/javafx-sdk-11.0.2/lib/javafx.graphics.jar"/>

我的 pom.xml 看起来像这样:

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.rulez.magwas</groupId>
    <artifactId>zenta3</artifactId>
    <version>3.0.0-SNAPSHOT</version>
  </parent>

  <groupId>zenta3-editor</groupId>
  <artifactId>org.rulez.demokracia.zenta3.editor</artifactId>
  <packaging>eclipse-plugin</packaging>

  <build>
    <plugins>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.1</version>
            <configuration>
                <mainClass>org.openjfx.App</mainClass>
            </configuration>
        </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <release>${jdk.version}</release>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <goals>
              <goal>java</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <mainClass>ZentaApplication</mainClass>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11.0.2</version>
    </dependency>
</dependencies>

</project>

父 pom 包含属性、repos 和以下 tycho 构建插件配置:

  <plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-packaging-plugin</artifactId>
    <version>${tycho-version}</version>
    <configuration>
      <archive>
        <manifestEntries>
          <Bundle-RequiredExecutionEnvironment>${jdk.full.version}</Bundle-RequiredExecutionEnvironment>
        </manifestEntries>
      </archive>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-maven-plugin</artifactId>
    <version>${tycho-version}</version>
    <extensions>true</extensions>
  </plugin>
  <plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>target-platform-configuration</artifactId>
    <version>${tycho-version}</version>
    <configuration>
      <executionEnvironment>${jdk.full.version}</executionEnvironment>
      <dependency-resolution>
        <extraRequirements>
          <requirement>
            <type>eclipse-plugin</type>
            <id>org.eclipse.osgi.compatibility.state</id>
            <versionRange>0.0.0</versionRange>
          </requirement>
        </extraRequirements>
      </dependency-resolution>
      <environments>
        <environment>
          <os>linux</os>
          <ws>gtk</ws>
          <arch>x86_64</arch>
        </environment>
        <environment>
          <os>win32</os>
          <ws>win32</ws>
          <arch>x86_64</arch>
        </environment>
        <environment>
          <os>macosx</os>
          <ws>cocoa</ws>
          <arch>x86_64</arch>
        </environment>
      </environments>
    </configuration>
  </plugin>
</plugins>

jdk.version 是 11,但也尝试了 10。 我记得我可以用 maven 编译它,但现在无法编译它。

错误:

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.4.0:compile (default-compile) on project org.rulez.demokracia.zenta3.editor: Compilation failure: Compilation failure: 
[ERROR] /project/mag/Zenta/zenta3/ui/src/main/java/org/rulez/demokracia/zenta3/editor/parts/handles/DeleteElementHandlePart.java: 
[ERROR]     package org.rulez.demokracia.zenta3.editor.parts.handles;
[ERROR]     ^
[ERROR] The type javafx.scene.paint.Color cannot be resolved. It is indirectly referenced from required .class files
[ERROR] /project/mag/Zenta/zenta3/ui/src/main/java/org/rulez/demokracia/zenta3/editor/parts/handles/DeleteElementHandlePart.java:[17] 
[ERROR]     public class DeleteElementHandlePart extends AbstractHandlePart<Group> {
[ERROR]                                                                     ^^^^^
[ERROR] Group cannot be resolved to a type
[ERROR] 2 problems (2 errors)

【问题讨论】:

    标签: eclipse maven tycho javafx-11


    【解决方案1】:

    将 javafx 的所有 jars 放到项目的 lib 文件夹中,并在 classpath 中列出它们很有帮助。但这似乎更像是一种变通方法而不是解决方案,我无法弄清楚如何设置产品的启动配置才能真正启动它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-14
      • 2019-08-09
      • 2020-07-31
      • 2015-10-08
      • 1970-01-01
      • 1970-01-01
      • 2019-07-20
      相关资源
      最近更新 更多