Intellij reporting that Java 9 module reads same package from two same modules
Answered
Hi,
I've got a project that requires javafx, so I've put in their requirements in the project's module-info.java file. However, I don't understand the error message I've getting, that the package javafx.scene.charts is being read from both the javafx.controls and javafx.controls module?
This isn't the first time I'm getting this sort of error. I've also gotten errors where the same javafx package is read from different javafx modules.
Is there something wrong with the way I've configured my project in intellij?
I've attached pics of my Intellij module dependencies and the error in the module-info.java file. If any more info is needed please do ask! Thanks!

Please sign in to leave a comment.
See
https://dba-presents.com/index.php/jvm/java/159-error-java-module-xyz-reads-package-org-apache-commons-logging-from-both-commons-logging-and-jcl-over-slf4j
https://stackoverflow.com/a/42358212/2000323
https://stackoverflow.com/a/53562029/2000323
You can exclude one of the dependencies groups: you have two javafx.controls dependencies in your list.
In my case, I did some reorg of maven modules and a lot of refactorings. After my work were done, I started to have this problem in module-info.java.
What helped me was to remove all *.iml files and reimport project again, with "clear caches and restart" in between.
Same problem with:
reads package 'javafx.scene.chart' from both 'javafx.controls' and 'javafx.controls'
It turns out, that I've installed Zulu JDK with fx (sdk install java 17.0.1.fx-zulu), so there was a conflict between JavaFX included in JDK and JavaFX imported into project through dependencies (Gradle's 'org.openjfx.javafxplugin' with 'javafx.controls' module).
I've fixed my problem by: sdk uninstall java 17.0.1.fx-zulu && sdk install java 17.0.1-zulu (+resetting JDK for project and two restarts of IntelliJ).