2

Every time I create a new JavaFX project in IntelliJ it loads a simple HelloWorld project in it. How can I make it empty instead (without the need to delete those .java files every time)? Also how can I choose to create the project without a building system (as you can see in the picture, I'm always forced to create the project with Maven or Gradle)

enter image description here

Henry Ecker
  • 31,792
  • 14
  • 29
  • 50
Youssef Idraiss
  • 182
  • 1
  • 13

1 Answers1

2

When creating the new project, choose "Java" instead of "JavaFX".

A JavaFX application is just a Java application, so if you don't want the additional things which IntelliJ is doing when you choose to create a JavaFX project (e.g. supplying example code and associating with a build system like Maven or Gradle), you can just choose a basic Java application project from the wizard and it won't do those other things.

See the section in openjfx.io documentation titled "JavaFX and IntelliJ IDEA" for other steps you need to take:

  1. Set the project JDK

    • File -> Project Structure -> Project
  2. Create a JavaFX library in Idea

    • File -> Project Structure -> Libraries
    • Point to the lib folder of the JavaFX SDK.
  3. Add VM options for the module path

    • Run -> Edit Configurations...

      --module-path /path/to/javafx-sdk-15.0.1/lib --add-modules javafx.controls,javafx.fxml
      

    For windows use quotes around the path and \ rather than /.

  4. Run the project

    • Run -> Run...

You might also need to take the actions identified in the accepted answer to:

But that answer was written a while back and setting the resource copy configuration to include JavaFX fxml and css files might not be needed anymore.

Now, you might think that is annoying amount of things to do, and I might agree with you.

jewelsea
  • 141,332
  • 12
  • 351
  • 391