简体   繁体   English

如何将 JavaFX 导入 Eclipse?

[英]How do I import JavaFX into Eclipse?

I have the latest JDK (update 65), but Eclipse doesn't even recognize JavaFX when I try to import it.我有最新的 JDK(更新 65),但是当我尝试导入它时,Eclipse 甚至无法识别 JavaFX。

How do I fix this and import it?我如何解决这个问题并导入它?

After following these steps完成这些步骤后

  1. Go Help去帮助
  2. Go Eclipse MarketPlace去日食市场
  3. Search e(fx)clipse搜索 e(fx)clipse
  4. Install it安装它

you can import javafx and if you want to add on your project just follow:您可以导入 javafx,如果您想添加到您的项目中,只需遵循:

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

Follow the steps:请按照以下步骤操作:

  1. Go Help去帮助

  2. Go Eclipse MarketPlace...去 Eclipse MarketPlace...

  3. Search e(fx)clipse搜索 e(fx)clipse

  4. Install It安装它

Do these following steps:执行以下步骤:

  1. Open Eclipse -> Help -> Eclipse Marketplace打开 Eclipse -> 帮助 -> Eclipse Marketplace
  2. Search for "javafx"搜索“javafx”
  3. You'll see e(fx)eclipse, install it.你会看到e(fx)eclipse,安装它。
  4. After installation, restart eclipse安装完成后重启eclipse
  5. Then create new project File > New > Project(don't select Java project).然后创建新项目 File > New > Project(不要选择 Java 项目)。
  6. Then Select JavaFX > JavaFX Project然后选择 JavaFX > JavaFX 项目
  7. Then click Next, give project name and click Finish然后点击下一步,给出项目名称并点击完成
  8. You'll get "The import javafx cannot be resolved"你会得到“无法解析导入的 javafx”
  9. Download JavaFX in here JavaFX在此处下载 JavaFX JavaFX
  10. Extract the folder and place it downloads folder (or anyplace)提取文件夹并将其放置下载文件夹(或任何地方)
  11. Then in eclipse right click the project and select properties然后在eclipse中右键单击项目并选择属性
  12. Choose Java Build Path选择 Java 构建路径
  13. Then select Libraries tab (you'll see tabs on the top)然后选择库选项卡(您会在顶部看到选项卡)
  14. You'll see Classpath > JavaFX SDK您将看到 Classpath > JavaFX SDK
  15. Click on Classpath, then click Add external JARs from the right.单击 Classpath,然后单击右侧的 Add external JARs。
  16. Then from the download JavaFX (placed in downloads folder or somewhere you've placed).然后从下载 JavaFX(放置在下载文件夹或您放置的某个地方)。
  17. Choose all the .jars file in Downloads/javafx-sdk-11.0.2/lib/(all .jar(s) file) and click open.选择 Downloads/javafx-sdk-11.0.2/lib/(all .jar(s) file) 中的所有 .jars 文件,然后单击打开。
  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.选择参数选项卡并在 VM 参数中键入。

 --module-path /path/to/JavaFX/lib --add-modules=javafx.controls,javafx.fxml

  1. (Important) Then uncheck the box that says "Use the -XstartOnFirstThread..." (重要)然后取消选中“使用 -XstartOnFirstThread...”框
  2. Click Apply and Run.单击应用并运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM