My current Eclipse is Oxygen.2 Release (4.7.2) and there's Java 9.0.1. Essentially Java 9 works and particularly auto import works (for "ordinary" classes and packages), but auto import (and autocompletion) does not work for javafx.*
. If I manually type import java
and press Ctrl+Space, then list of matching packages pops up where I can see javafx.*
hierarchy. But when I type e.g. import javafx.stage
and press Ctrl+Space it automatically adds .*;
and does not display any classes in the package. When I type Stage
somewhere in the method body and press Ctrl+Space, there are no suggestions for it. However when I type add an import (like import javafx.stage.Stage
) then code compiles and runs.
Any clues how to fix auto completion and auto import feature (which, as I said, works for other classes, like for instance java.time.LocalDateTime
or many othres).
javafx*
classes are blocked during code completion due to access rules governing the access to system packages. Looking at, e.g., Eclipse bug 527353 the mechanism for dynamically computing the list of accessible packages had not been finalized in Eclipse Oxygen. As a result, only a static profile can be used. That file currently mentions:
NOTE: The JavaSE-9 profile is not yet finalized.
Since dynamic computation according to JEP 261 includes the javafx
packages - if available -, I think the static profile should list those as well, or be abandoned in favor of fully relying on JPMS rules, only.
You can, however, avoid the problem by explicitly defining an access rule granting access to javafx/**
at
Java Build Path > Libraries > JRE System Library > Access rules
.