Alex
Alex

Reputation: 18542

Explanation of module dependencies Java

I'm sure this is probably a duplicate question, but I'm trying to understand why...

I'm not looking for advice really - I've only got 5 modules in the project so it's no big deal. I'm just curious as to why this is the case (or maybe I am missing something obvious).

Upvotes: 2

Views: 71

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726967

There are two kinds of dependencies to consider - project dependencies, and run-time dependencies.

Run-time dependencies are the simplest ones: you need JARs for both A and B in order to run C, because without A, B would not be able to run. Java modules are similar to dynamic libraries in other compiled languages (as opposed to static libraries). When you compile B, the compiler does not make copies of A's classes to be included with B: it assumes that A, B's dependency, will be available at run-time.

Project dependencies are less straightforward: strictly speaking, you do not need to include A in the list of dependencies of C. Most development environments will figure out transitive dependencies for you, so when A changes, B would recompile, and then C would recompile in response to B's recompile.

Upvotes: 1

Related Questions