DEV Community

Java Lover
Java Lover

Posted on

How to Set Up JavaFX in IntelliJ IDEA with Maven

There are some options to start working with JavaFX to build Graphical User Interface (GUI) using Java programming language. The documentation has explained the JavaFX installation in various code editors, like NetBeans, Eclipse, Visual Studio Code, and IntelliJ IDEA. The easiest one is to set up JavaFX in IntelliJ IDEA with the Maven project because you don't need to download JavaFX SDK or set up the library.

Per this article published, the newest JavaFX version is 20.0.1 and it needs at least Java JDK 17 to install. Make sure the JDK is added to the System Variable Path and set the JAVA_HOME environment variable. You can go to this article to do all that stuff.

  • After Java 17 was installed, open IntelliJ IDEA and click New Project
  • In the left bar (Generators), choose JavaFX
  • Then, specify Name and Folder Location of your project and change Group and Artifact name
  • The most important part is the SDK, make sure you choose the installed Java JDK version, and click Next
  • In the Additional Libraries window, you can select the libraries you want to work with to simplify JavaFX project development, and click Create

Image description

IntelliJ IDEA will download all dependencies needed, so it will take a while. After finishing, the project structure will look like the following image.

Image description

Open pom.xml file, and make sure there are two main dependencies (javafx-controls and javafx-fxml) and one plugin javafx-maven-plugin. In some cases, those dependencies are not the latest version. You can check the latest version in this link for javafx-controls and this link for javafx-fxml.

Image description

Image description

To test and run the application, open HelloApplication.java file, then click the green color play button. It will show the GUI like the following image.

Image description

Congratulation!!! You succeed in creating the first GUI application using JavaFX framework.

Top comments (0)