The import javafx.scene.control.Alert cannot be resolved

冷暖自知 提交于 2019-12-05 10:20:07

问题


I am getting the error with following two imports in Eclipse:

import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;

The errors are: "The import javafx.scene.control.Alert cannot be resolved" and same is true for the 2nd import statement.

I am using Eclipse Version: Luna Service Release 2 (4.4.2) and have installed e(fx)clipse with latest JDK 1.8 (1.8.0_45).

There is no problem with other javafx related import statements, such as

import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.input.MouseEvent;

回答1:


I had the same problem, until I installed the JDK 1.8.0_60. That's right, installing the latest JDK helped!

After you install the latest JDK, change the settings on the Eclipse There are two steps to the process:

  1. Select the appropriate JRE in Eclipse > Preferences > Java > Installed JREs as shown here:

    1. In Project > Properties > Java Build Path, Add Library as depicted below:



回答2:


I got the same problem on Eclipse (MacOSX Yosemite) this morning but yesterday everything worked... To solve the problem I just deselected the checkbox for another JDK in Project > Properties > Java Build Path restarted Eclipse, reselected the good one (JDK 1.8.0_60), restarted Eclipse again and voilà ! Just a weird bug with checkboxes...

Hope it ll help you.




回答3:


You need to change the java version. Java 1.8.0_45 do not include javafx.scene.control.Alert You can download version 1.8.0_221 here



来源:https://stackoverflow.com/questions/30393751/the-import-javafx-scene-control-alert-cannot-be-resolved

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