I want to create hello world java 9 application and start it in intellij idea.
Now I have following structure:
content of inner module-info.java:
module my.module.Second {
requires my.module.First;
}
content of outer module-info.java:
module my.module.First {
exports my.pack;
}
But idea complains about my project:
Error:(1, 1) java: too many module declarations found
I don't understand why it happens and what really wrong. So
My question is how to force idea to accept my hello world.
P.S. From the first glance error looks obvious but I have project which I downloaded from github with the same structure but it works properly and idea doesn't complain about it:
From the main menu, select File | New | Module from Existing Sources. In the dialog that opens, specify the path the . iml file of the module that you want to import, and click Open. By doing so, you are attaching another module to the project without physically moving any files.
IML is a module file created by IntelliJ IDEA, an IDE used to develop Java applications. It stores information about a development module, which may be a Java, Plugin, Android, or Maven component; saves the module paths, dependencies, and other settings.
According to Oracle Jar file specification
A modular JAR file is a JAR file that has a module descriptor, module-info.class, in the top-level directory (or root) directory.
One Jar could contain only one module.
To fix you problem you have to split your project (create several maven modules)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With