Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Monday, October 20, 2014

Access Restriction in Eclipse: The Type FXML is not API

When upgrading to Java 8, I noticed that all the FX references in my Java source were flagged with a warning in my Eclipse IDE (including the latest, Luna).  This warning is caused by shipping FX as an extension rather than a co-located JAR.  Since most projects stick to one Java compiler (Oracle versus IBM), this can be safely turned off.

In previous versions of Java, Java FX was either shipped in the /lib folder to be added to a classpath or as a separate download.  In Java FX 8, Java FX is added as an extension.  See the following screenshot taken from the Eclipse IDE (Luna) for the difference in treatment between rt.jar and jfxrt.jar.

JavaFX JAR Added as an Extension
This produces the following warnings in the Java source.

Eclipse Warning of Use of Extension
And the fix is to navigate to the build settings to turn off the Forbidden References warning.

Turn Off Forbidden Reference Warnings
This particular project is based on Maven, and Maven doesn't produce any such warnings about the use of the extension.  So, it's safe to turn off.  This wasn't an issue with my Java 6 and Java 7 uses of FX because in those cases, I explicitly added Java FX to the classpath which makes it portable to other Java installations. 

2 comments:

  1. Thank you very much. You post saved me a lot of time!

    With best wishes,
    Markus

    ReplyDelete