i am currently on my way to convert some of my projects from Oracle JDK8 + JavaFX8 to OpenJDK11 + OpenJFX11. At the moment im trying to understand how to use OpenJFX11 as library via maven. I used maven before, love the easy dependency management.
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.
This is the relevant part of my 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. 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.
When i launch this project from the commandprompt via maven
mvn compile exec:java
It runs fine and the JavaFX Application pops up.
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.
I tried to create a Maven launch configuration with exactly the same parameters:
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).
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
Thanks in advance