JavaFX does not exist using Java 9 and Intellij Idea

20,528

Solution 1

Try to set project language level to "9" in "Project Structure | Project"

Solution 2

Okay I see what my problem was.

Besides Try to set project language level to "9" in "Project Structure | Project" mentioned above, I had a maven setting in some pom.xml looks like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin.version}</version>
    <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>
    </configuration>
</plugin>

and java.version was defined as 1.8 somewhere above. I just had to change it to 9

Solution 3

I had this problem after upgrading a JavaFX project from Java 8 to Java 9.

After checking the usual language level settings for the project and module in IntelliJ and the Maven pom, I found the problem was that the module was explicitly set to generate Java 8 bytecode in the Java Compiler preferences.

Look in Preferences -> Build, Execution, Deployment -> Compiler -> Java Compiler. Check that Project bytecode version is unset (or set correctly) and that your module is not listed in Per-module bytecode version with an incorrect value.

Solution 4

File --> Project Structure-->Module

The language level in here as set to 5 for me. Upped it to 9 to allow classes etc and the same error as described above resolved for me.

Solution 5

I missed the modules in my gradle.build. Had to update

javafx {
  version = "11"
  modules = [ 'javafx.controls', 'javafx.fxml' ]
}
Share:
20,528
user3785637
Author by

user3785637

Updated on August 12, 2022

Comments

  • user3785637
    user3785637 over 1 year

    I am using Intellij Idea to compile a project that uses Maven dependencies and Intellij keeps telling me that my project has 50 something errors because JavaFX does not exist.

    Intellij is not highlighting all the javafx dependencies in my code as errors, it is just that once I press the run and compile the program says that everything in JavaFX does not exists.

    I tried to redownload the latest JDK (Java 9.0.1) and that did not fix it. I went into the Default Project Structure and Project Structure to make sure it was using the correct jdk and that did not fix the issue. All the jdks I am using seem to list the javafx packages as included in the project.

    This is also only an issue for a particular project that I am working on with a friend. We may have to move over all our code into a new project, however I am not sure if that will fix anything.

    Any suggestions?

  • Fuyang Liu
    Fuyang Liu over 6 years
    I have the same issue, and this seems not helping. Any other idea why?
  • mipa
    mipa about 6 years
    Did you read the previous answers and comments? What new information is your answer giving?
  • Mejmo
    Mejmo over 5 years
    And what if I do not want to have 9 as a target? I just want to compile the project so that it can run on both JDK8 and JDK9/10. If I compile it for target 9, it will not work on 1.8.
  • Jenny
    Jenny over 4 years
    Actually helped, since I could not find where Project Structure was located