无法让 JavaFX 在 Eclipse 中工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27913114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:20:00  来源:igfitidea点击:

Cannot get JavaFX to work in Eclipse

javaeclipse

提问by user3226170

I'm trying to use JavaFXin Eclipse but whenever I use any of it's Classes it doesn't recognize the type. To clarify I get the message "Dropshadow cannot be resolved to a type"

我正在尝试JavaFX在 Eclipse 中使用,但是每当我使用它的任何类时,它都无法识别类型。为了澄清我收到消息"Dropshadow cannot be resolved to a type"

This happens not only with Dropshadow, but with any of the JavaFXclasses. The IDE won't give me an option to import it and when I try and to type it in manually it isn't recognized. In using JSE 8u25, which apparently has it included.

这不仅发生在 Dropshadow 中,而且发生在任何JavaFX类中。IDE 不会让我选择导入它,当我尝试手动输入它时,它无法识别。在使用中JSE 8u25,显然包含它。

In looking around I see that the .jar filecan be added manually, but I would like to know if something within my IDE isn't configured right, because it should be working. Can anybody give me a hand with this? Thanks.

环顾四周,我发现.jar file可以手动添加,但我想知道我的 IDE 中的某些内容是否配置不正确,因为它应该可以正常工作。任何人都可以帮我解决这个问题吗?谢谢。

回答by user3226170

So I finally got it working, the solution was to install the eclipse plugin found here:

所以我终于让它工作了,解决方案是安装这里的 eclipse 插件:

http://www.eclipse.org/efxclipse/install.html

http://www.eclipse.org/efxclipse/install.html

The directions are pretty good, I just followed them as written and got it up and running.

指示非常好,我只是按照书面说明进行操作并启动并运行。

回答by Cristian Babarusi

The simple way to solve your issue is to right click your project, go to properties > java build path then select the tab where it says Libraries. You have to select that library you have in there > click the button EDIT then select from there Workspace default JRE . You need to have at least java 8.

解决您的问题的简单方法是右键单击您的项目,转到属性> java 构建路径,然后选择显示库的选项卡。您必须选择您在那里拥有的库 > 单击按钮 EDIT 然后从中选择 Workspace default JRE 。你至少需要有 java 8。

回答by Cristian Babarusi

Adding to Build Path

添加到构建路径

Your problem here, is that you just dropped your .jarfile right in there, and tried using it. You need to addit to the project. To do so, follow the below steps:

您的问题是,您只是将.jar文件放在那里,然后尝试使用它。您需要添加到项目中。为此,请按照以下步骤操作:

  1. Add the .jarfile to your project folder(not src) via. copy/paste or simply drag/drop.
  2. Right click on the .jarfile once it's inside your project.
  3. Press Build Path > Add To Build Path
  1. 通过将.jar文件添加到您的项目文件夹(不是src)。复制/粘贴或简单地拖/放。
  2. .jar一旦文件位于您的项目中,请右键单击该文件。
  3. Build Path > Add To Build Path

What you have/will done, is adding the .jarto the project itself. Theres a difference between having it inyour project, and having it a partof your project.

您已经/将要做的是将 加入.jar到项目本身中。您的项目中使用它和将它作为您项目的一部分是有区别的。

Now you can import, extend, implement, whatever you need.

现在你可以import, extend, implement, 无论你需要什么。



Removing from Build Path

从构建路径中删除

Ok, so you found a better library for what you want, no longer need the library or made your own, and you want to delete your .jar.

好的,所以您找到了一个更好的库来满足您的需求,不再需要该库或创建自己的库,并且您想删除您的.jar.

Well, firstly, it's stilla partof your project, so you need to remove it from the Build Path first.

嗯,首先,它仍然您项目的一部分,因此您需要先将其从 Build Path 中删除。

  1. Right click on the .jarfile.
  2. Press Build Path > Remove from Build Path
  1. 右键单击该.jar文件。
  2. Build Path > Remove from Build Path

Your .jaris stillinsideyour project, but no longer a partof it.

.jar还在里面你的项目,但不再的一部分吧。

Now you may go ahead and delete it without worry.

现在您可以继续删除它而不必担心。