Joselin Jocklingson
Joselin Jocklingson

Reputation: 181

Cannot import class in eclipse

I've installed Eclipse Luna Service Release 2 (4.4.2) on my Windows Vista 32-bit system.

When creating a Java project I can

import com.sun.javafx.application.*;

without errors, but when I type

import com.sun.javafx.application.Application;

the import statement gets underlined.

Under the project's had Java build path I can see the entries:

JRE System Library [JavaSE-1.8] JRE System Library

[CDC-1.0/Foundation-1.0]

No matter which one I click, the error won't go away.

What should I do?

Upvotes: 2

Views: 311

Answers (1)

howlger
howlger

Reputation: 34137

com.sun.javafx.application.Application is part of the Java 8 system library but not of the JavaSE-1.8 execution environment which is only a subset of the Java 8 system library (e. g. all com.sun.* sub-packages are excluded in the execution environments).

To get access to the whole system library, choose an Alternate JRE instead of an Execution Environment (in the Java Build Path select JRE System Library [JavaSE-1.8] JRE System Library and click Edit...).

As long as no class is used, import com.sun.javafx.application.*; is not an error but only an unused import statement.

See also How does Eclipse know that com.sun is a restricted API?

Upvotes: 1

Related Questions