-1

I've tried to search everywhere to find a solution for this problem but no solution is present on the internet, it seems.

I'm using Ubuntu 18.04.1 LTS and visual studio code, while everything else seems to work, I'm not able to use the import statement. It gives error, stating "javafx could not be resolved".

enter image description here

I've installed javafx on my system but it is not available for use in VS code

enter image description here

what can i do to fix this?

Slaw
  • 37,820
  • 8
  • 53
  • 80
Mohit Tomar
  • 160
  • 1
  • 11
  • 2
    Add the jars your classpath. – Thorbjørn Ravn Andersen Jan 04 '20 at 09:32
  • How to do that? – Mohit Tomar Jan 04 '20 at 09:36
  • Does [JavaFX-11 with VSCode](https://stackoverflow.com/q/54349894/6395627) help? – Slaw Jan 04 '20 at 09:42
  • Please don't post question-related information, or ask a new question, in the answer section. You should either [edit] your question (if you're providing more/clarifying information) or [ask a new one](https://stackoverflow.com/questions/ask) (if you have an entirely different question). – Slaw Jan 05 '20 at 06:55
  • The solution given on this page worked for me: https://stackoverflow.com/questions/16868446/javafx-exception-in-thread-main-java-lang-noclassdeffounderror-javafx-applica – Mohit Tomar Jan 05 '20 at 12:39
  • **DO NOT post images of code, data, error messages, etc.** - copy or type the text into the question. [ask] – Rob Apr 02 '20 at 11:23

1 Answers1

0

In your .classpath file, all you have to do is add entries for all the JavaFX jar files you want to load (probably all). Just be wary of moving the jar files as the error will then return. Then you should see the JavaFX libraries under your classpath and the compiler will then be able to resolve it.

Tag Howard
  • 194
  • 1
  • 11
  • I installed Eclipse 2019 and tried to add jars under Windows > Preferences > Java > Installed JRE > Edit > Add External Jars and added all the required jars. The problem of not able to resolve the class is gone but somehow now I get the error of "NoClassDefFound". What can I do about that? – Mohit Tomar Jan 05 '20 at 05:15
  • @MohitTomar I'm not sure why you installed Eclipse if you're trying to use VS Code. Or have you decided to switch IDEs? – Slaw Jan 05 '20 at 06:56
  • 1
    @Slaw: Actually it seemed that vsCode was too hard to deal with as most of the settings were only possible through copy and pasting codes from online forums like stackOverflow. I'm new to programming and wanted something easy and intuitive. Moreover I see that eclipse is widely used and a lot of help is available for eclipse so I decided to change from vsCode to Eclipse and will stick to it. – Mohit Tomar Jan 05 '20 at 12:37
  • Also I'm able to find the solution to the problem. I've shared the solution below. – Mohit Tomar Jan 05 '20 at 12:38