JavaFX错误:类文件的版本号为54,应该为52

时间:2019-02-09 20:06:12

标签: java maven intellij-idea javafx

我安装了Java JDK 11,并且正在使用Maven JavaFX。但是,当我尝试运行代码时,出现构建错误,即“类文件的版本54错误,应为52”

POM.xml

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11.0.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>11.0.2</version>
    </dependency>

    <dependency>
        <groupId>com.ibm.watson.developer_cloud</groupId>
        <artifactId>java-sdk</artifactId>
        <version>6.14.0</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
    </dependency>
</dependencies>

1 个答案:

答案 0 :(得分:2)

确保使用Java 11进行编译,并且语言级别设置为10或更高。检查this answer以获得有关如何在IntelliJ IDEA for Maven中配置语言级别的详细信息。