Skip to content

How to create a JavaFX project within another project and open it in IntelliJ

I wanna add JavaFX to an existing project in IntelliJ and followed this documentation.

I created a folder structure with an folder with an JavaFX project in it. If I open only this folder who contains JavaFX within IntelliJ everything gets imported correctly and the sample main is running. If I open the whole project where the folder with JavaFX is an subfolder only I get a lot of red and running the main results in many errors. How can I open a JavaFX project within another project in IntelliJ?

IntelliJ Project structure if it does work

GUI
+-- JavaFXRelatedFiles

IntelliJ Project structure if it does not work

+-- src
|   +-- GUI
|   +-- OtherFolder

Answer

Choose File | New Module... instead of File | New Project....

The setup of the new module after that will be similar to the new project, so you can just follow the instructions you linked for creating a new JavaFX project.

If you want to link the multiple modules together with a Maven build, that is much more complex (especially if you use both maven and java platform modules), so I won’t describe that process here.