0

I recently have updated Eclipse to version 2019-12 and my JDK to Java SE 13, and I learned afterwards that this JSE no longer includes JavaFX as a core library. So, I looked up the Maven dependency entries for newer JavaFX libraries compatible with JSE 13 and picked version 11. I added them to my pom.xml file as such:

<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>...</modelVersion>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>...</version>
    <url>https://github.com/.../url>
    <name>...</name>
    <description>...</description>

    <dependencies>
        ...
        ...
        <!-- JavaFX is no longer included in JDK --> 
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>11</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11</version>
       </dependency>
       <dependency>
           <groupId>org.openjfx</groupId>
           <artifactId>javafx-fxml</artifactId>
           <version>11</version>
       </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

However, now some javafx imports in my source files cannot be resolved. For example:

import javafx.application.Application; //Application class not found
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.paint.Color; //Color class not found

I’ve checked the javadocs for the javafx...Application and javafx...Color classes, and it appears they should be included among the class files within the graphics, controls, and fxml modules I linked as dependencies in the pom.xml file.

Why are my imports not resolving?

1

1 Answer 1

2

Oh never mind. I was bumbling with this for a couple hours before I tried bumping up to JavaFX 13 in my Maven dependencies and now everything works.

:/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.