6

I have the latest JDK (update 65), but Eclipse doesn't even recognize JavaFX when I try to import it.

How do I fix this and import it?

0xCursor
  • 2,242
  • 4
  • 15
  • 33
TheSuds13
  • 327
  • 2
  • 3
  • 8
  • 1
    Have a look at http://stackoverflow.com/questions/15592775/javafx-is-not-recognized-in-eclipse and http://download.java.net/general/javafx/eclipse/tutorial.html – Balwinder Singh Nov 20 '15 at 04:36
  • You can add `jfxrt.jar` to your project build path. – LifeAndHope Nov 20 '15 at 04:38
  • Always specify the JDK version, not only the update number. The "latest" for you when you wrote the question, may not be the same "latest" for who is reading now. – henriqueor Apr 22 '20 at 23:01

3 Answers3

9

Do these following steps:

  1. Open Eclipse -> Help -> Eclipse Marketplace
  2. Search for "javafx"
  3. You'll see e(fx)eclipse, install it.
  4. After installation, restart eclipse
  5. Then create new project File > New > Project(don't select Java project).
  6. Then Select JavaFX > JavaFX Project
  7. Then click Next, give project name and click Finish
  8. You'll get "The import javafx cannot be resolved"
  9. Download JavaFX in here JavaFX
  10. Extract the folder and place it downloads folder (or anyplace)
  11. Then in eclipse right click the project and select properties
  12. Choose Java Build Path
  13. Then select Libraries tab (you'll see tabs on the top)
  14. You'll see Classpath > JavaFX SDK
  15. Click on Classpath, then click Add external JARs from the right.
  16. Then from the download JavaFX (placed in downloads folder or somewhere you've placed).
  17. Choose all the .jars file in Downloads/javafx-sdk-11.0.2/lib/(all .jar(s) file) and click open.
  18. Then click Apply and Apply and close.
  19. Then you won't get red underlines or (error).
  20. Then right click on project > Run as > Run configuration
  21. Choose the arguments tab and type this in VM arguments.

    --module-path /path/to/JavaFX/lib  --add-modules=javafx.controls,javafx.fxml
  1. (Important) Then uncheck the box that says "Use the -XstartOnFirstThread..."
  2. Click Apply and Run.
Praveen
  • 91
  • 2
  • 4
5

After following these steps

  1. Go Help
  2. Go Eclipse MarketPlace
  3. Search e(fx)clipse
  4. Install it

you can import javafx and if you want to add on your project just follow:

Java Build Path -> Libraries -> Add Libraries-> JavaFx SDK

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Dasrath
  • 366
  • 2
  • 11
3

Follow the steps:

  1. Go Help

  2. Go Eclipse MarketPlace...

  3. Search e(fx)clipse

  4. Install It

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93