IntelliJ IDEA 中的 JAVA 11 和 JavaFX

标签 java maven intellij-idea javafx fxml

我在 IntelliJ IDEA 2018 中创建了 JavaFX 项目。我已经安装了 Java JDK 11,我的项目 (Maven) 包括所有需要的依赖项:

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>11</version>
    </dependency>
</dependencies>

但是当我尝试启动应用程序时,我得到:
    Error:(3, 26) java: cannot access javafx.application.Application
  bad class file: C:\Users\Baterka\.m2\repository\org\openjfx\javafx-graphics\11\javafx-graphics-11-win.jar(javafx/application/Application.class)
    class file has wrong version 54.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

问题出在哪里?什么是版本 54 和 52?新的 Java 11 是否支持 JavaFX?

最佳答案

尝试将其添加到您的 pom.xml 文件中。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>11.0.1</source>
                <target>11.0.1</target>
            </configuration>
        </plugin>
    </plugins>
</build>

如果您也更新所有 Maven 插件会更好。看到这个 youtube link ,这就是我得到配置的地方。

关于IntelliJ IDEA 中的 JAVA 11 和 JavaFX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52933987/

相关文章:

java - 如何构建(gwt + jsf 2.0 + spring),jboss

java - 从属性文件访问 Maven Pom 变量

java - Maven 模块 - 如何在不相关的项目中将其用作外部库

java - 无法解析 JSP 中的方法 getParameter()

html - Intellij - 左边距中的 CSS 颜色框

java - SonarQube @NoArgsConstructor( Lombok 项目)

java - 在不同模式的android中打开手电筒

java - Java 12 无法访问 org.openqa.selenium.chrome.ChromeDriver 类型

JAVA - 错误不兼容类型 : String cannot be converted to String[ ]

java - 为什么这个字符口导致我的扫描仪失败?