I've been trying to set up on JavaFX in VSCode. I added the JavaFX jar files to the referenced libraries and added the following statement to launch.json
(obviously with my path to the lib folder):
"vmArgs": "--module-path \"C:/path/to/javafx-sdk-19/lib\" --add-modules javafx.controls,javafx.fxml"
This is exactly what multiple youtube videos and other StackOverflow posts have said to do, but I still keep getting this error.
(I know that I can use Maven or Gradle in VScode but am completely unfamiliar with both and still want to try to make this work.)
Hopefully I didn't miss anything painfully obvious but thank you for any help.
CodePudding user response:
- You should download JavaFX for your JDK version.
- Uncompress JavaFX.zip and move bin folder to your project.
- You should create two classes, one for writing the JavaFX window code and one for running it.
The error can be fixed.
I suggest you learn how to use Maven or Gradle in vscode. It is very important.
CodePudding user response:
At runtime, your app needs access to the JavaFX (OpenJFX) libraries.
Either:
- Install a copy of the OpenJFX libraries with your app, as directed in the Answer by RedSnack-BCS.
- Replace your Java implementation with one that includes the OpenJFX libraries.
I know of two such implementations of Java (JDKs) that include necessary libraries:
- ZuluFX, a special edition of their Zulu product, by Azul Systems.
- LibericaFX, a special edition of their Liberica product, by BellSoft.
You may have identified a third approach with the use of passing arguments to the JVM. But I am not familiar with that solution.