eclipse JavaFx API版本和运行时错误

时间:2016-04-04 13:38:21

标签: java eclipse javafx scenebuilder

image

每当我尝试运行我的代码时,都会收到此错误消息?

2 个答案:

答案 0 :(得分:1)

If you have a look at the FXMLLoader source code you'll find that warning message:

private void processValue() throws LoadException {
    ...
    // checking the version JavaFX API - print warning if not supported
    String defaultNSURI = xmlStreamReader.getNamespaceContext().getNamespaceURI("");
    if (defaultNSURI != null) {
        String nsVersion = defaultNSURI.substring(defaultNSURI.lastIndexOf("/") + 1);
        if (compareJFXVersions(JAVAFX_VERSION, nsVersion) < 0) {
            Logging.getJavaFXLogger().warning("Loading FXML document with JavaFX API of version " +
                            nsVersion + " by JavaFX runtime of version " + JAVAFX_VERSION);
        }
    }
    ...
}

As the comment says, it is checking if the current JRE JavaFX version (based on System.getProperty("javafx.version")) is lower than the version specified in the FXML file.

Scene Builder 8 sets that value whenever you create a new file in the so called name space FX value, based on the very same property:

private static final String NAME_SPACE_FX = "http://javafx.com/javafx/" + FXMLLoader.JAVAFX_VERSION;

If you run your project in other machine with an older version of JavaFX you will get this warning. Notice it is just a warning, not an error, that advises of the required JavaFX version.

Anyway, you can easily get rid of this warning, by editing the FXML file and lowering the required version:

xmlns="http://javafx.com/javafx/8" 

答案 1 :(得分:0)

尝试更新您的java: