I am trying to create a very simple java modules project in IntelliJ with multiple modules.
Accordingly documentation in https://openjdk.org/projects/jigsaw/quick-start#multimodulecompile inside src directory, each module should have its own directory.
so i organized my project like this:
src/easytext.analysis/module-info.java
src/easytext.analysis/com/msantos/pluralsight/java9modules/easytext/analysis/World.java
src/easytext.cli/module-info.java
src/easytext.cli/com/msantos/pluralsight/java9modules/easytext/cli/Main.java
As you can see, IntelliJ gives an error: 'module-info.java' already exists in the module
Yet if i compile from the command line i have no issues:
javac --module-source-path src/main/java/ -d out $(find . -name '*.java')
Could someone explain to me why IntelliJ gives that error (taking in consideration that is a valid structure from java point of view) and how to fix it?
Thank you so much in advance
IntelliJ with modules
After defining the modules, the compilation works, but now adding dependencies to the modules, it reveals that modules have no access to each other. The compilation from the command-line again is working.
Modules
easytext.analysis module
module easytext.analysis {
exports com.msantos.pluralsight.java9modules.easytext.analysis;
}
it exposes the package to the world
easytext.cli module
module easytext.cli {
requires easytext.analysis;
}
It defines a dependency on easytext.analysis module
Yet as we can see from the picture, no access to the package. Why is that?



Your setup is an unusual one, since you want to have multiple Java modules inside a single Maven module. This likely trips up IntelliJ, since it maps Maven modules to IntelliJ modules. It certainly doesn't help that these three uses of "module" are three different things.
If you plan to package your Maven module into a single jar later, note that the Java module system does not allow more than one module per jar file. I recommend turning your project into a multi-module Maven project, with each Java module becoming a dedicated Maven module.