Installing Java and JavaFX
Install Java 21 JDK
- Download Windows/x64
.msi
build from here (be sure to click on the Java 21 tab to ensure you are getting the correct version) - Open the
.msi
file to install JDK21
Install JavaFX 21
- Download x64 JavaFX 21 Windows SDK from here and unzip the file
- Select Windows for the Operating System
- Select x64 for the Architecture
- Select SDK for the Type
- Copy the
javafx-sdk-21.0.2
1 folder from the.zip
file toC:\Program Files\Java\
Install Scene Builder 21.0.0
- Download Scene Builder Windows Installer from here
- Open the
.msi
file to install Scene Builder
Configure IntelliJ
Set the Project SDK
- Go to File -> New Projects Setup -> Structure
- Select Project under Project Settings on the left side
- Set SDK to 21 (if available); otherwise:
- Click Add SDK
- Select JDK and browse to
C:\Program Files\Java\jdk-21
2
- Under Project language level select SDK default
- Click OK
Add JavaFX to Global Library
- Go to File -> New Projects Setup -> Structure
- Select Global Libraries under Platform Settings on the left side
- Click the + (plus symbol) in the upper left of the second column
- Select Java from the menu
- Browse to
C:\Program Files\Java\javafx-sdk-21.0.2\lib
(adjust to match version) - Change Name from lib to javafx
- Click OK twice
Set Run Configuration Template for Application
- Go to File -> New Projects Setup -> Run Configuration Templates...
- Select Application
- Click Modify options (or type Alt+M) and ensure Add VM options is checked
- Paste the following in VM options:
--module-path "C:\Program Files\Java\javafx-sdk-21.0.2\lib" --add-modules=javafx.controls,javafx.fxml
- Here too, ensure that the version number matches what you downloaded
- Click OK
New IntelliJ Project
All of the steps above must be implemented once, but you'll need to do the following for each new IntelliJ project.
- Create a Java (not JavaFX) project, if you create a JavaFX project, you will need to set the run configuration (as described above).
Add the JavaFX SDK library
- Go to File -> Project Structure... (CTRL+ALT+SHIFT+S)
- Select Modules
- Open the Dependencies tab and click +
- Select Library...
- Within your JavaFX installation, select the javafx folder.
- Click Add Selected and then OK
1
You may need to update the version number on the javafx-sdk in a similar way to a JDK version change.
2
If the version of the JDK is different, you will need to use the new version number in the rest of the instructions. E.g., if the version of JDK is 21.0.2, you should replace jdk-21
with jdk-21.0.2
.