How To Install IntelliJ 2021.1 for JavaFX 16, JDK 16, Scene Builder 16 on Windows 10 x64

Опубликовано: 30 Сентябрь 2024
на канале: Ken
3,473
43

In this tutorial, I will show you how to install IntelliJ IDEA 2021.1 so that you can work with JavaFX 16, JDK 16, JavaFX Scene Builder 16 on Windows 10 x64. JavaFX 16 needs at least Java Development Kit (JDK) 11 or later.

- How To Install JDK 16 on Windows 10 x64,    • How To Install JDK 16 on Windows 10 x64  
- How To Install JavaFX 16 on Windows 10 x64,    • How To Install JavaFX 16 on Windows 1...  
- How To Install JavaFX Scene Builder 16 on Windows 10 x64,    • How To Install JavaFX Scene Builder 1...  

You should download and install the following:

- JDK 16 is available from https://www.oracle.com/java/technolog...

- Open JavaFX (OpenJFX) 16 is available from https://gluonhq.com/products/javafx/
- Java Scene Builder 16 is available from https://gluonhq.com/products/scene-bu...
- IntelliJ IDEA Community Edition 2021.1 is available from https://www.jetbrains.com/idea/download/

The Installed directories are as following:

C:\Program Files\Java\jdk-16
C:\Program Files\Java\javafx-sdk-16
C:\Users\Ken\AppData\Local\SceneBuilder
C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1

With the release of JDK 11 in 2018, Oracle has made JavaFX part of the OpenJDK under the OpenJFX project. It means that Oracle JDK 11 is no longer comes with JavaFX 11. To continue use JavaFX, we may choose to use current long-term version (JDK 8) through March 2025 or use OpenJFX 11 or higher after integrated into installed JDK.

It means that you have to do certain things by yourself.

1. Create a new JavaFX project.

Add JDK and specify the path to the JDK home directory (for example, C:\Program Files\Java\jdk-16).

Java: package javafx.application does not exist

2. Add the JavaFX 16 library. You make sure your project is configured to run with JDK 11 or later, and you may add the JavaFX 16 library.

for example, C:\Program Files\Java\javafx-sdk-16\lib.

Error: JavaFX runtime components are missing, and are required to run this application

3. Use VM options to run the the application. You have to integrate JavaFX modules/jars into installed JDK if you use Java 11 or higher.

3.1 From the main menu, select Run | Edit Configurations.
3.2 Select Application | Main from the list on the left.
3.3 From the More options list, select Add VM options.
3.4 In the VM options field, specify the following options,

--module-path "C:\Program Files\Java\javafx-sdk-16\lib"
--add-modules javafx.controls,javafx.fxml

Leaving a space between the two module names, like this: --add-modules=javafx.controls, javafx.fxml, may result in a syntax error. Therefore, it is important to ensure that there is no space between the module names when using the --add-modules option with JavaFX.

3.5 Apply the change and close the dialog.

4. Run the JavaFX application (e.g. Main.java) with Run 'Main'.

#IntelliJ #JavaFX16 #Java16 #SceneBuilder