'idea: too many module declarations found

I want to create hello world java 9 application and start it in intellij idea.

Now I have following structure:
enter image description here

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

Question:

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:

enter image description here



Solution 1:[1]

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)

Solution 2:[2]

Just import your Java modules.

From the main menu, select File | New | Module from Existing Sources.

Select the directory in which your sources, libraries, and other assets are located and click Open.

In the dialog that opens, select Create module from existing sources if you want to create a new module from the existing source code.

Reference: https://www.jetbrains.com/help/idea/creating-and-managing-modules.html#import-module-from-sources

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Gyschuk
Solution 2 danyfang