IntelliJ doesn't recognize JavaFX imports
Answered
I've got JavaFX in my Gradle dependencies/got the plugin, it shows all the JavaFX's JAR files under external libraries and it just doesn't work. It just gives me an error "package javafx.fxml does not exist". I have tried checking that my Java version is correct, project bytecode version, JavaFX plugin installed, JavaFX installed and i even added the JAR-s manually but nothing works. I also tried reinstalling IntelliJ.
Please sign in to leave a comment.
Please delete the System directory: https://www.jetbrains.com/help/idea/tuning-the-ide.html#system-directory when the IDE is not running.
That did not work.
When do you get the error, in the editor or when compiling?
Please share a sample project to reproduce the issue: https://uploads.jetbrains.com.
Make sure the project is set up according to https://www.jetbrains.com/help/idea/javafx.html.
See also https://openjfx.io/openjfx-docs/ .
2021_03_15_WYSi5mnUdcVK3hZL
Both, in the editor and when compiling.
The issue is with your project, not with IntelliJ IDEA.
First problem is that the import statement is incorrect:
Should be changed to this:
The second problem is that you do not specify JavaFX modules to be used in the module dependencies.
cScripts\scripts\cChompy\build.gradle.kts needs to be updated with something like this:
javafx {modules = listOf("javafx.controls", "javafx.fxml", "javafx.web")
version = "15.0.1"
}
Thank you so much!
This piece of code fixed it.
It's documented here: https://openjfx.io/openjfx-docs/#gradle . Please always follow the official documentation before asking questions.