简体   繁体   English

通过Maven的OpenJDK 11 + OpenJFX 11无法在Eclipse 2018-09 + Java 11修补程序中运行

[英]OpenJDK 11 + OpenJFX 11 via maven fails to run inside Eclipse 2018-09 + Java 11 Patch

i am currently on my way to convert some of my projects from Oracle JDK8 + JavaFX8 to OpenJDK11 + OpenJFX11. 我目前正在将我的一些项目从Oracle JDK8 + JavaFX8转换为OpenJDK11 + OpenJFX11。 At the moment im trying to understand how to use OpenJFX11 as library via maven. 目前,我正试图了解如何通过maven将OpenJFX11用作库。 I used maven before, love the easy dependency management. 我以前使用过Maven,喜欢简单的依赖管理。

I understood it that way, that when i just add openjfx as pom dependencies maven handles it completely and i dont need to configure anything java module related. 我这样理解,当我将openjfx添加为pom依赖项时,maven会完全处理它,而我不需要配置任何与Java模块相关的东西。

This is the relevant part of my pom: 这是我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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  [...]

  <dependencies>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.11.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.11.1</version>
    </dependency>

    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-base</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>
  </dependencies>

  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>11</source>
                <target>11</target>
            </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>[My Mainclass]</mainClass>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>

As you see i initally want to have Log4J2 and the BAsic JavaFX modules as dependencies for my project. 如您所见,我最初希望将Log4J2和BAsic JavaFX模块作为我项目的依赖项。 AS i already had problems with launching OpenJFX11 Apps via maven at all i stumbled up on this thread: Different behaviour between Maven & Eclipse to launch a JavaFX 11 app So i have my Entry main Class and my JavaFX extended Application class seperated from each other, only one calling the other to launch the application. 就像我通过maven启动OpenJFX11应用程序时遇到问题一样,我偶然发现了这个线程: Maven和Eclipse的行为不同,无法启动JavaFX 11应用程序,所以我的Entry主类和JavaFX扩展Application类彼此分离,只有一个调用另一个来启动该应用程序。

When i launch this project from the commandprompt via maven 当我通过Maven从命令提示符启动该项目时

mvn compile exec:java

It runs fine and the JavaFX Application pops up. 它运行良好,并弹出JavaFX应用程序。

What i cant do right now is create an launch configuration inside eclipse which will start my application inside Eclipse so i can use the eclipse debugger for example. 我现在不能做的是在eclipse中创建启动配置,该配置将在Eclipse中启动我的应用程序,因此我可以使用eclipse调试器作为示例。 I tried to create a Maven launch configuration with exactly the same parameters: 我试图用完全相同的参数创建一个Maven启动配置: 在此处输入图片说明

But when i launch this configuration it fails with the following stacktrace: 但是,当我启动此配置时,它将失败并显示以下堆栈跟踪:

[WARNING] 
java.lang.NoSuchMethodError: <init>
    at com.sun.glass.ui.win.WinApplication.staticScreen_getScreens (Native Method)
    at com.sun.glass.ui.Screen.initScreens (Screen.java:412)
    at com.sun.glass.ui.Application.lambda$run$1 (Application.java:152)
    at com.sun.glass.ui.win.WinApplication._runLoop (Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3 (WinApplication.java:174)
    at java.lang.Thread.run (Thread.java:834)
[WARNING] 
java.lang.NoSuchMethodError: <init>
    at com.sun.glass.ui.win.WinApplication.staticScreen_getScreens (Native Method)
    at com.sun.glass.ui.Screen.initScreens (Screen.java:412)
    at com.sun.glass.ui.Application.lambda$run$1 (Application.java:152)
    at com.sun.glass.ui.win.WinApplication._runLoop (Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3 (WinApplication.java:174)
    at java.lang.Thread.run (Thread.java:834)
[WARNING] 
java.lang.NullPointerException
    at com.sun.prism.d3d.D3DPipeline.getAdapterOrdinal (D3DPipeline.java:205)
    at com.sun.javafx.tk.quantum.QuantumToolkit.assignScreensAdapters (QuantumToolkit.java:695)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runToolkit (QuantumToolkit.java:313)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$startup$10 (QuantumToolkit.java:258)
    at com.sun.glass.ui.Application.lambda$run$1 (Application.java:153)
    at com.sun.glass.ui.win.WinApplication._runLoop (Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3 (WinApplication.java:174)
    at java.lang.Thread.run (Thread.java:834)

This seems to me as there are native libraries or methods missing and nothing directly in my project. 在我看来,这是因为缺少本机库或方法,并且在我的项目中没有直接的内容。 But normally the javafx dependency should automatically add the system natives (win in my case, it appears under maven dependencies). 但是通常javafx依赖项应自动添加系统本机(在我看来,win是在maven依赖项下出现)。

All i found was this thread, but i cant really create a solution for my problem out of it: NoSuchMethodError: <init> in com.sun.glass.ui.win.WinApplication.staticScreen_getScreens 我发现的只是该线程,但是我无法为它的问题真正创建解决方案:com.sun.glass.ui.win.WinApplication.staticScreen_getScreens中的NoSuchMethodError:<init>

Thanks in advance 提前致谢

OK, i deinstalled all java instances and eclipse from my system. 好的,我从系统中卸载了所有Java实例和Eclipse。 Reinstalled eclipse and it seems to be working like a charm now. 重新安装了eclipse,它现在看起来像是一种魅力。 Probably was a environment problem causing eclipse to launch with the worng native libraries. 可能是环境问题导致Eclipse随随便便的本机库一起启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM