How to create a JavaFX Maven project in IntelliJ IDEA?

javafx-maven-plugin
javafx modules
openjdk javafx
install javafx
javafx project
javafx eclipse
javafx 15
javafx jar

How can I open a JavaFX Maven project from scratch in IntelliJ IDEA? As there is no difference between a Java project and a JavaFx project, I want to open a dedicated JavaFX project (Selection JavaFX from create project Wizard) with Maven module included.

Although dated I'm answering this because I had the same question recently and too many people told me to write my own pom file etc. While that is technically true, it can create more headaches if you aren't careful.

I recommend you:

  1. Create a JavaFX project as you normally would.
  2. Make sure that project view (dropdown in project structure side tool window) is set to 'Project' or 'Packages' (otherwise option in 4th step will not be visible)
  3. Then once it is opened and ready right click on the project folder
  4. Go to "Add Framework Support...".
  5. Check the box for Maven and click "OK".

Let IntelliJ do the work for you at this point.

As for editing FXML files link the IDEA to SceneBuilder. Here is the official documentation. But basically:

  1. Install Scene Builder.
  2. File -> Settings -> Languages & Frameworks -> JavaFX
  3. Point to the exe file.

To Use: Right click on the FXML file and select "Open In SceneBuilder" (way down at the bottom)

JavaFX, Easiest Setup, IntelliJ + Maven (2019), This tutorial will help you to write a JavaFX 14 application and run it on desktop (e.g. maven/gradle) to download the required modules from Maven Central. Create a new project. When you create a new JavaFX project, IntelliJ IDEA generates a fully configured sample application. Launch IntelliJ IDEA. If the Welcome screen opens, click Create New Project. Otherwise, from the main menu, select File | New | Project. In the New Project wizard, select JavaFX from the list on the left. From the Project SDK list, select the JDK that you want to use in your project.

And after all, a program doesn't compiled. So this video helped me: Configuring Maven For Java FX

in words: we need to move sample.fxml to /resources folder. And in Main.java write:

FXMLLoader loader=new FXMLLoader(getClass().getResource("/sample.fxml"));

Getting Started with JavaFX, For information on how to create modular and non-modular projects with Maven or Gradle, refer to Getting Started with JavaFX. Troubleshoot. Error: JavaFX  Create Maven Project IntelliJ – IntelliJ Idea comes with fully integrated with Maven default version which will help your project to configure/automate build process. In IntelliJ you can easily create maven java project OR you can open sync with existing project OR add maven to any existing project.

This steps worked for me (Is a different process): 1. Create a maven project. 2. In the generated pom.xml add the following:

`<build>
        <plugins>
            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>8.7.0</version>
                <configuration>
                    <mainClass>your.package.with.mainclass</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>`

This adds a maven plugin for javafx (more info: https://github.com/javafx-maven-plugin/javafx-maven-plugin)

  1. Create in your resources folder your sample.fxml
  2. Create your controller class for sample.fxml and link
  3. Enjoy!

Create a new JavaFX project - Help, to build project. IntelliJ IDEA generates target folder. Note that IntelliJ IDEA only compiles sources and doesn't create either JAR file or Manifest file. In this Video I am going to show How to Create a JavaFX Project in IntelliJ IDEA Using Scene Builder. How to convert a normal java project in intellij into a JavaFx. How to create a JavaFX module

It takes me a couple of hours to find the right solution. Many thanks to this video and the author: https://www.youtube.com/watch?v=qn2tbftFjno

So, following the above video, I would like to recommend:

  1. Download JavaFX SDK from https://gluonhq.com/products/javafx/
  2. Extract the zip file
  3. From the starting page of Intellij IDEA, select Configure/Structure for New Projects
  4. Select Platform Settings/Global Libraries
  5. Select the plus ("+") button/Java
  6. Find the "lib" folder inside your extracted zip file and select all of ".jar" files (except "src.zip"), and then OK
  7. Set a new name for the library, let's say "javafx-whatever-version", then Apply/OK
  8. Create a JavaFX project as normally.
  9. Select File/Project Structure...
  10. From Project Settings/Project, remember to select the suitable Project SDK and Project language level
  11. From Platform Settings/Global Libraries, right click on the library "javafx-whatever-version" (which you have already added), choose Add to modules.../OK
  12. Switch to Project Settings/Modules, choose Apply/OK
  13. Back to your project manager, right click on "src"/New/module-info.java
  14. Add new lines to the body of module-info.java:
requires javafx.fxml; 
requires javafx.controls; 
opens sample;
  1. Run the project and enjoy!

Add Maven support to an existing project, How do I create an existing project as a Maven project in IntelliJ? You can open an existing non-Maven project and add a Maven support via IntelliJ IDEA UI. Open an existing project, for example, a Java project. In the Project tool window, right-click your project and select Add Framework Support. In the dialog that opens, select Maven from the options on the left and click OK.

Package JavaFX applications - Help, IntelliJ IDEA creates the artifact for packaging the application together with the project. However, you can create a new artifact configuration with your custom  Importing a Maven project in IntelliJ IDEA. This tutorial explains how to import an existing Maven project into IntelliJ IDEA and how to create a running configuration for a Maven goal.

JavaFX Tutorial: Getting started, How to set up and start working with JavaFX using Maven, Gradle, or JavaFX SDK. All posts in the JavaFX series. JavaFX Tutorial: Getting started; JavaFX Tutorial: Hello world · JavaFX In IntelliJ IDEA, you can simply go to:. Non-Modular project; JavaFX and IntelliJ. Report a problem Run HelloWorld via Maven. Report a problem Use IntelliJ IDEA Use NetBeans Use Eclipse.

JavaFX with Maven and IntelliJ : JavaFX, I tried creating new Maven JFX project in Netbeans and to import that in IntelliJ but it wouldn't work no matter how I tried. Netbeans does seem to compile and run  Launch IntelliJ IDEA. Click on Create New Project. Select Maven build tool from the left menu. Check the option Create from archetype. Select the quickstart archetype to create a simple java project and click on Next button. Enter groupID,artifactID details for your project. Optionally, you can override the default paths for settings.xml and local repository .m2 folder. Hit on Finish button to create the java maven project. To import changes to the maven project automatically, click on

Comments
  • This appears to be a useful answer for a project which in not based on Maven. I suspect, if Maven were involved, the answer would be a little bit different because the Idea Maven integration would already add the required JavaFX libraries to the compile path for project (but not necessarily to the runtime java module system module path). Perhaps in such a case the answer would be similar to the answers for IntelliJ can't recognize JavaFX 11 with OpenJDK 11
  • My mistake, thank you @jewelsea for recommendation. Anyway, I hope it will help someone by somehow at least.
  • It's a useful recipe to setup a JavaFX project in Idea, it will help someone :-)