JavaFX does not exist using Java 9 and Intellij Idea

I use Intellij Idea to compile a project that uses Maven dependencies, and Intellij keeps telling me that my project contains 50 errors because JavaFX does not exist.

Intellij does not highlight all the javafx dependencies in my code as errors, just after I click on run and compile the program, it says that everything in JavaFX does not exist.

I tried to download the latest version of the JDK (Java 9.0.1), and this did not fix it. I went into the project structure and the default project structure to make sure that it was using the correct jdk, and that didn't solve the problem. All the jdks I use seem to list the javafx packages included in the project.

This is also a problem only for the specific project I'm working on with a friend. We may need to move all of our code to a new project, but I'm not sure if this fixes something.

Any suggestions?

+6
source share
5 answers

Try setting the project language level to "9" in "Project Structure | Project"

+11
source

Well, I understand what my problem was.

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

 <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

+10
source

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 the module in IntelliJ and Maven pom, I found that the problem is that the module is explicitly installed to generate Java 8 bytecode in the settings of the Java compiler.

See Preferences -> Build, Execution, Deployment -> Compiler -> Java Compiler . Make sure that Project bytecode version not installed (or installed correctly) and that your module is not listed in the Per-module bytecode version with the wrong value.

+5
source
 File --> Project Structure-->Module 

The language level here for me is 5. Increase it to 9 to allow classes, etc., And the same error is resolved for me as described above.

0
source

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

 javafx { version = "11" modules = [ 'javafx.controls', 'javafx.fxml' ] } 
0
source

Source: https://habr.com/ru/post/1273505/


All Articles