Question

maven dependency not found with Java FX 19 on Eclipse 2024-06 but not earlier

I have the following issue with Eclipse 2024-06: A project that references

    <dependencies>
        <!-- Java FX -->
        <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-base -->
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>19</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>19</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-swing</artifactId>
            <version>19</version>
        </dependency>
    </dependencies>

in its pom.xml shows the error org.openfx:javafx-base:jar:${javafx.platform}:19 was not found in https://repo1.maven.org/maven2.

This error is not there in earlier versions of Eclipse (e.g., Eclipse 2024-03).

How can I work on Java 11/17 Projects that reference JavaFX 11/19 in the latest version of Eclipse?

Notes:

  • The error also exists if you have a project that references a dependency that references JavaFX. So upgrading JavaFX is not (always) an option, if you need to work with some given dependency.

  • The error also comes up if you set the <version> to 22, but it is gone if you set the <version> to `23-ea+22

  • The property ${javafx.platform} is not defined in the projects pom.xml but Eclipse shows that the property is defined with Default Value: mac.

 2  94  2
1 Jan 1970

Solution

 3

This is a issue in Maven 3.9.7 which is also mentioned in this answer. It was addressed in Maven 3.9.8.
Apparently, the issue is due to profile IDs in the JavaFX artifacts:

In short, OpenJFX parent provides invalid POM since 2021. The crux is that parent POM uses conflicting Profile IDs, that simple Maven validation shows (as one can expect, fields having "ID" in their name are supposed to be, well, "identifiers"):

As Eclipse 2024-06 uses that Maven version as the embedded Maven version, you will get this error in Eclipse as well.

Option 1: update JavaFX

It seems like this problem was also handled on JavaFX' side with the latest versions.

So, one way to fix this is to update to a different JavaFX version like 21.0.4 or 22.0.2 (I would avoid ones with -ea in the version name if possible as these are early access builds but you can also go with 23-ea+22 as you already noticed).

As you can see in the POM of JavaFX 21.0.3 for example, there are multiple profiles with the same <id>. This is not the case for JavaFX 21.0.4 which uses different profile ids

Option 2: update the M2Eclipse plugin

Alternatively, you could update m2e to version 2.6.2 or later (which is currently a snapshot meaning it might have other bugs!). To do this, you need to add the snapshot update site for m2e 2.6.2 (in principle, you could also use https://download.eclipse.org/technology/m2e/snapshots/latest/ if you also want future m2e snapshots but I wouldn't recommend that unless you know what you are doing and are ok with encountering some bugs because of that).

You can do so from the Install New Software dialog:
Help > Install New Software

Click the Add button and add a new repository with the URL https://download.eclipse.org/technology/m2e/snapshots/2.6.2/:
Add new repository

Select that repository as well as M2E - Maven Integration for Eclipse, click Next and install it:
enter image description here

This should change the embedded Maven version to 3.9.8 as you can see in Window>Preferences>Maven>Installations:
The embedded Maven version is 3.9.8

2024-07-21
dan1st