Let's say I have 2 modules:
module1 has the package package1
module2 has package2
, package3
and package4
I want package1
to be visible to only package2
in module2. not to any other packages (package3
or package4
) in module2.
Is this possible using module-info.java?
No, this is not possible. You can only export a package to the whole module:
module module1 {
exports package1 to module2;
}