Step by step guide on how to set up JavaFX on IntelliJ
If you want to learn how to write web apps in java, the easiest way to get started is install JavaFX on IntelliJ. Or if you are used to a different IDE, there are JavaFX installs for the most common ones.
I’m going to show you how to install it on IntelliJ, running on Windows 10.
In this simple, step by step tutorial, I’ll show you how to set up JavaFX in IntelliJ.
OpenJFX is an open source, next generation client application platform for desktop, mobile and embedded systems built on Java.
Before we get started, make sure you are all set for it. You need at least:
- Windows XP or newer operating system
- Minimum JDK 11(preferably JDK 14) version
- Any common IDE (we will be suing IntelliJ)
- 512 MB of RAM (preferably min 1 GB)
- 256 MB of free disk space
Step 1
Visit https://openjfx.io/ and scroll to the bottom of the page to the getting stared section.
The simplest way is setting up JavaFX using Maven. Maven is an automation tool; it handles all build dependencies for you.
Form the menu on the left hand side, chose JavaFX and IntelliJ, then Modular with Maven.
Maven
Follow these steps to create a JavaFX modular project and use the Maven tools to build it and run it.
Step 2
Select File -> New -> Project -> Maven and enable Create from archetype. If the JavaFX archetype is not installed yet, select Add archetype… and set the groupId (org.openjfx), the artifactId (javafx-maven-archetypes), and the version (0.0.1), and press ‘OK’. Then click ‘Next’.
Step 3
Provide the groupId, like org.openjfx, the artifactId, like hellofx then click ‘Next’.
Step 4
Select the archetype artifactId, between javafx-archetype-fxml or javafx-archetype-simple, based on the use of FXML or not in your project. We are starting with a simple project, so for now, we will or javafx-archetype-simple. Double click on the field, and a pop-up window appears. There, you can override the Value field. Then press ‘OK’.
Step 5
Now, you have to add JavaFX version. Click on the ‘+’ button in the top right corner to add a new propertty. In the pop-up window, you can create a property for the javafx-version as well, and set it to 14. Then click on ‘Finish’.
Step 6
Finally, provide a Project name, like HelloFX and a location for the project. Then click on ‘Finish’ again.
Step 7
Only one last step left, where we have to verify if our installation has worked. The pom.xml file should open automatically, but if it hasn’t just navigate to it We have to look at our pom.xml file, and check if it includes the javafx.controls and javafx.fxml dependencies, and includes the javafx-maven-plugin.
Step 8
Now you are all set with your JavaFX installation. A sample project has been created with the installation. To open it, navigate to src -> main -> java -> org.openjfx -> App