Reputation: 69
A java newbie here. I wanted to learn about JavaFX on VSCode but when I launch my JavaFX it gave me this error. I tried to add referenced Library and the configurations vmArgs
on launch.json
on the project, but it giving me the same thing.
Here is my config.
"vmArgs": "--module-path C:/Users/vince/Downloads/javafx-sdk-17.0.1/lib --add-modules javafx.controls,javafx.fxml"
Can anyone help me please ?
Upvotes: 6
Views: 13491
Reputation: 1
"vmArgs": "--module-path \"enter_the_path_here_of_lib(Refrenced_Library not lib present in your project folder)\" --add-modules javafx.controls,javafx.fxml"
Upvotes: 0
Reputation: 1
If you still get this error after setup "vmAgrs", and your using debug/launch-(F5)-to start your App, its possible that VSCode wouldn't launch your "App.java" file, instead will try to launch "Current file" which is something else..
To fix it just change "Launch Current file" to "Launch App" from "Start debugging" in "Run and Debug" icon.
Anyway if any of this didn't work, you could Run it manually by:
1st compile using javac
javac --module-path "PATH\javafx-sdk-19.0.2.1\lib" --add-modules javafx.controls App.java
2nd Run it..
java --module-path "PATH\javafx-sdk-19.0.2.1\lib" --add-modules javafx.controls App
thanks to Casey LINK
Upvotes: 0
Reputation: 116
Solution: You simply need some edits in your "vmAgrs" in the "launch.json" file
"vmArgs": "--module-path \"C:/Users/vince/Downloads/javafx-sdk-17.0.1/lib\" --add-modules javafx.controls,javafx.fxml"
General form of the solution:
"vmArgs": "--module-path \"enter_the_path_here\" --add-modules javafx.controls,javafx.fxml"
Use this and your code should work perfectly.
I was having the same problem and wasted almost 4 hours solving this. I used this video here: link! as reference. (Caution: the video is in Portuguese)
Upvotes: 5
Reputation: 1
Try putting everything on one drive other than C. I had my codes in D drive and JavaFX in C, the codes never launched successfully. It didn't work even when I put the codes in the JavaFX folder. However, once I transferred JavaFX files to D drive, it worked.
Upvotes: -1
Reputation: 1285
Check out the samples here: https://github.com/openjfx/samples/tree/master/IDE/VSCode
You can probably use this one, which I guess is the one you are looking for.
Upvotes: 1
Reputation: 69
I didn't fix the javafx in my vs code, but i switched IDE to Eclipse and JavaFX run smoothly after adding VMargs to the run configuration on Eclipse
Upvotes: 0