javaeclipsejavafxazul-zulu

Javafx imports won't work in eclipse with zulu fx jdk


I am trying to convert my eclipse project which uses the fx package to use the zulu jdk 16 with its integrated fx (jdk 16.0.1+9 Zulu: 16.30.15). However, it just doesn't work.

None of the javafx imports work, while the other imports are just fine. When I hover over the fx classes in my application (like "Application", lol) it even recommends me to import it and everything just seems fine with no errors until I save my project and the error reappears. Before saving I can even open the documentation of the Application class - consequently it's clearly there - but eclipse just won't accept it after saving. I even checked the modules of my jdk, but everything seems to be fine there (see here).

I am using the newest stable version of eclipse (2021-06 (4.20.0)). I know there is a very old bug where eclipse randomly won't accept imports anymore, but in this case every fix I tried didn't work and the problem only occurs for all javafx imports.

The error is "The import javafx.scene cannot be resolved"


Solution

  • Apparently I was able to fix the problem myself. It seems like it was just the usual old eclipse bug with its imports - idk why the previous fixes aimed for this problem didn't work.

    I managed a proper rebuild by...
    "project" -> "properties" -> "Java Build Path" -> select the JRE -> "Edit" -> tick "Execution environment" (or sth other if it is already selected) -> select some JavaSE version (used 1.16) -> "Finish" -> "Apply"

    And this fixed the errors in my case.