JAVA 11 and JavaFX in IntelliJ IDEA

Viewed 4500

I created JavaFX project in IntelliJ IDEA 2018. I have installed Java JDK 11 and my project (Maven) includes all needed dependencies:

<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>

But when I try to launch app, I am getting:

    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.

Where is problem? What are versions 54 and 52? Is JavaFX supported in new Java 11?

2 Answers

try adding this to your pom.xml file.

<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>

It would be better if you update all your maven plugins also. see this youtube link, that's where I got the configuration.

Related