Module moduleA not found in module source path , trying to compile

GOXR3PLUS :

After this question was answered i published java 9 modules tutorials + examples on Github and how to run for future users :

I have the below very simple structure:

src 
│   module-info.java
│ 
└───moduleA
    └───pack1
            Main.java

module-info.java :

module moduleA {

}

Main.java:

package moduleA.pack1;
public class Main{

 public static void main(String[] args){
   System.out.println("Hello Java 11");
 }
}

And i am trying to compile and then run this modular java application which is very simple .

So from the cmd i am running :

Compile

javac --module-source-path src -d out -m moduleA

Run

java  --module-path out -m moduleA/pack1.Main

enter image description here

From IntelliJ it works like charm , i don't know what magic it runs behind .

What am i doing wrong ?

ZhekaKozlov :

--module-source-path is usually used to compile multiple modules at once. But of course, you can compile a single module with it if you want. However, you have to move the source files to the directory with the module name:

src
└───moduleA
    │───module-info.java
    └───moduleA
        └───pack1
            └───Main.java

Also, you should fix the command line which runs your module:

java --module-path out -m moduleA/moduleA.pack1.Main

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=76922&siteId=1