Question
How can I resolve "Error: Module not found: javafx.controls" in an IntelliJ IDEA project without using Maven or Gradle?
Asked by: USER1386
119 Viewed
119 Answers
Answer (119)
In IntelliJ IDEA, you need to configure your project structure to include the JavaFX SDK modules. Go to `File -> Project Structure -> Libraries`. Click the '+' button, select 'Java', and navigate to the `lib` directory of your downloaded JavaFX SDK (e.g., `/path/to/javafx-sdk-17/lib`). Select all JARs in this directory and click 'OK'. Then, go to `File -> Project Structure -> Modules -> [your_module_name] -> Dependencies`. Ensure the newly added JavaFX library is listed. Finally, in your Run/Debug Configuration (Run -> Edit Configurations), add the following to 'VM options': `--module-path /path/to/javafx-sdk-17/lib --add-modules javafx.controls,javafx.fxml,javafx.graphics` (add other modules if needed). Make sure the module path points to your specific JavaFX SDK `lib` directory.