Module Graph Problem with 2018.2
Answered
Upgrading from 2018.1.6 to 2018.2 has introduced a problem with Module dependencies
Using JDK 10.0.2, all javafx import statements show errors similar to the following
"Package javafx.fxml is declared in module javafx.fxml, which is not in the module graph"
Switching to JDK 1.8 resolves the problem. The problem can also be resolved by creating a 'module-info.java' file with the appropriate entries such as
"requires transitive javafx.fxml"
What has changed in 2018.2 to create this issue ? Is it now necessary to use a 'module-info.java' ?
Please sign in to leave a comment.
It looks like Java 9/10 module system requirement not specific to IntelliJ IDEA.
Your projects will fail to build without the proper module-info.java when using Java 9/10 and IntelliJ IDEA corresponds to the Java compiler behavior showing the same errors.
Thanks Serge
The problem does not occur with 2018.1.6 so it appears that something changed in IDEA which introduced the problem.
Although using module-info.java is a reasonable solution, it does not work with JAR files that do not include module-info. It is not an easy task to convert JAR files to Module JAR files when using third party libraries such as SOAP API libraries
Regards
Des
If you don't want to use the new module system, you have to stick to Java 8.
Your comment does not explain why this changed from 2018.1.6 to 2018.2
Clearly the alternative is to continue using earlier versions of IDEA
2018.1 could work incorrectly and not follow the module system specs properly. There were some related fixes in 2018.2.
If you believe it's a bug and the specs are not followed correctly, please file a bug at https://youtrack.jetbrains.com/issues/IDEA with the sample project to reproduce attached.
Thanks Serge
You are correct.
In 2018.1, the setting for the LANGUAGE_LEVEL in the project .iml file did not make any difference. Changing between JDK_1_8 and JDK_10 had no effect.
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_10" inherit-compiler-output="true">
In 2018.2, the LANGUAGE_LEVEL is now working correctly so that the LANGUAGE_LEVEL is enforced. Setting it to JDK_1_8 will now disable the features beyond this level. I have not tested this but I assume this problem applied to other features in addition to modules.
Des
Because IDEA is now correctly enforcing the use of modules-info.java, are there plans to automatically generate this file using the import information in the source ? This was the original intention of using modules.
IntelliJ IDEA provides assistance for module-info editing: https://blog.jetbrains.com/idea/2017/03/support-for-java-9-modules-in-intellij-idea-2017-1/.
Hi, I have changed 2018 Ultimate to Community, Ultimate Version worked with JavaFX correctly, but Community show this problem:
"Package javafx.application is declared in module javafx.fxml, which is not in the module graph"
"Package javafx.fxml is declared in module javafx.fxml, which is not in the module graph"
"Package javafx.scene is declared in module javafx.fx
ml, which is not in the module graph"
"Package javafx.stage is declared in module javafx.fxml, which is not in the module graph"
Could you answer in a short way please, my English is not so good to understand all the answers above, thanks!
Check your language level settings (here on screenshots: http://stackoverflow.com/a/12900859/104891). Using 1.8 language level may fix the issue.
What's the purpose of this? To make writing code harder? I mean like seriously, I have this problem for like 10 hours, I thought there is some problem with my system! For someone who is still learning JavaFX this was a bad move! Why can't IntelliJ auto import these modules?
I just wanna know, why IntelliJ IDEA DOES NOT AUTO-IMPORT JAVAFX MODULE? (Like previous versions?)
Import from what format? Report at https://youtrack.jetbrains.com/issues/IDEA with a sample to reproduce.
I will try to explain the situation.
2018.2 is now working correctly for JDK 9 and JDK 10 because it is necessary to create modules-info.java. Any JDK after 1.8 will need this.
Prior to 2018.2, IntelliJ did not enforce this requirement. This issue is not related to JavaFX
The modules-info.java should look like this
module myModule {
requires transitive javafx.base;
requires transitive javafx.graphics;
requires transitive javafx.controls;
exports com.mycode to javafx.graphics, javafx.fxml;
opens com.mycode to javafx.graphics, javafx.fxml;
}
replace 'myModule' with a name of your choice and 'com.mycode' with your package name
Sorry, I missed one line in the modules-info.java
module myModule {
requires transitive javafx.fxml;
requires transitive javafx.base;
requires transitive javafx.graphics;
requires transitive javafx.controls;
exports com.mycode to javafx.graphics, javafx.fxml;
opens com.mycode to javafx.graphics, javafx.fxml;
}
Thank you for explaining this clearly. From my reading of this modular implementation, we need to require modules to be used, but also for reflection, to open packages for access by the required modules. That said, is there a need to both open and export a package in a simple, single module program? My (working) modules-info.java file looks like this: