Directory Structure
. ├── out │ └── calc-module │ ├── com │ │ └── ngsharma │ │ └── ocp │ │ └── Calculator.class │ └── module-info.class └── src └── calculator ├── com │ └── ngsharma │ └── ocp │ └── Calculator.java └── module-info.java
Successfully compile and generate the out/calc-module directory.
javac -d out/calc-module src/calculator/module-info.java src/calculator/com/ngsharma/ocp/Calculator.java
module-info.java
module calc {}
Calculator.java
package com.ngsharma.ocp;
public class Calculator {
public static int add(int i1, int i2) { return i1 + i2; }
public static void main(String[] args) {
System.out.println(add(20,40));
}
}
When i compile this module in following command.
1. java -p out --add-modules calc-module com.ngsharma.ocp.Calculator
When i'm using this command, it throw exception FindException: Module calc-module not found.
According to 1. module inside name and module directory name should be same other throw FindException.
2 java -p out --add-modules calc com.ngsharma.ocp.Calculator
but in this situation i'm not using module directory name i'm using only module-info.java inside file name, and successfully run. How..? and Why..?
module file name and module folder name should be same, otherwise not compile and run it is corrent or not.Please anybody suggest me and correct me what is my mistake.(newbie in module).