How do I import JavaFX into Eclipse?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-08 17:01:24

问题


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?


回答1:


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




回答2:


Follow the steps:

  1. Go Help

  2. Go Eclipse MarketPlace...

  3. Search e(fx)clipse

  4. Install It




回答3:


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.


来源:https://stackoverflow.com/questions/33819052/how-do-i-import-javafx-into-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!