user5182503
user5182503

Reputation:

Modules A and B export package some.package to module C in Java 9

I have three modules module-a, module-b and module-c. When I run my application I get the following:

Error occurred during initialization of boot layer java.lang.module.ResolutionException: Modules module-a and module-b export package some.package to module module-c

What does it mean, taking into consideration that module-c doesn't import some.package and how to fix it?

Upvotes: 24

Views: 8463

Answers (1)

Nicolai Parlog
Nicolai Parlog

Reputation: 51180

Looks like you've created a split package, meaning two modules (module-a and module-b in your case) contain the same package (some.package). The module system does not allow that. If you place both modules on the module path, you will get this error regardless of whether the package is exported or whether a third module depends on the other two.

The fix is, not to create modules that share the same package. This is not only a technical solution, it also improves the design by making sure each module has a specific and unique API.

Upvotes: 9

Related Questions