Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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;
like image 580
Nadeem Avatar asked May 22 '15 09:05

Nadeem


People also ask

How do I fix JavaFX error?

If this is your case also, you can do fix this by simply right-clicking on the javaFX project folder-> Build Path-> Configure Build Path-> Select JavaFX SDK-> Remove library-> Select classpath -> add library-> user library-> select library-> apply. Save this answer.


2 Answers

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

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: enter image description here

    1. In Project > Properties > Java Build Path, Add Library as depicted below: enter image description here
like image 106
user2922935 Avatar answered Oct 11 '22 08:10

user2922935


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.

like image 35
Central Thinking Unit Avatar answered Oct 11 '22 10:10

Central Thinking Unit