// module-one/module-info.
java
module module.one {
exports mypack;
}
// module-one/mypack/Person.java
package mypack;
public class Person {
private String name;
public Person(String name) {
this.name = name;
}
public Person() {
this.name = "Unknown";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
// module-two/module-info.java
module module.two {
requires module.one;
}
// module-two/Main.java
import mypack.Person;
public class Main {
public static void main(String[] args) {
Person person = new Person();
person.setName("P1");
System.out.println("Person's Name: " + person.getName());
}
}
module-one/
├── module-info.java
└── mypack/
└── Person.java
module-two/
├── module-info.java
└── Main.java