1

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 ?

Abra
  • 15,674
  • 6
  • 30
  • 39
mc ser
  • 11
  • 2
  • Not related to your question but. I advise moving the sdk out of the download directory to sonewhete more permanent. – jewelsea Jan 10 '22 at 06:37
  • I don’t know vscode, but comparing your arguments to a [similar question](https://stackoverflow.com/questions/54349894/javafx-11-with-vscode), the arguments look ok, so I don’t know how to fix that. – jewelsea Jan 10 '22 at 06:53
  • @jewelsea i did try to move my javaFX jdk to another place and updated it to VMargs but still same – mc ser Jan 10 '22 at 06:54
  • You could switch to a jdk that includes JavaFX, e.g. an appropriate version of [liberica](https://bell-sw.com/pages/downloads/#mn) or corretto, then you don’t need any arguments, or try idea with the [new project wizard](https://www.jetbrains.com/help/idea/javafx.html) which is an easy way to get started. – jewelsea Jan 10 '22 at 06:57
  • A past question like this was solved by [escape quoting the path](https://stackoverflow.com/questions/15637429/how-to-escape-double-quotes-in-json), but I don’t think that is your issue here. – jewelsea Jan 10 '22 at 06:59
  • @jewelsea just tried to escape quoting path still same tho – mc ser Jan 10 '22 at 07:11
  • Set `args` in launch.json, does it help? – Molly Wang-MSFT Jan 10 '22 at 09:26
  • @MollyWang-MSFT nope, i tried to add vmArgs and im sure the path is correct – mc ser Jan 10 '22 at 10:28
  • 1
    @mcser. After adding vmArgs, please restart VS Code to make the change effective. – Molly Wang-MSFT Jan 11 '22 at 02:16

2 Answers2

0

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.

Sheng Chen
  • 432
  • 2
  • 13
  • very useful, thanks – littlejedi Jan 11 '22 at 02:33
  • It would be good if this answer included a code snippet or something in the answer for the bit which makes “ (probably this one) which is suitable for you. ” Pull requests and forks can get deleted which would render this largely link only answer useless. – jewelsea Jan 11 '22 at 04:31
  • I'll update the answer once the PR is merged. – Sheng Chen Jan 20 '22 at 00:40
0

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

mc ser
  • 11
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 14 '22 at 11:49