In general: what is compile- and run-time dependencies
Compile-time dependency: You need the dependency in your CLASSPATH
to compile your artifact. They are produced because you have some kind of "reference" to the dependency hardcoded in your code, such as calling new
for some class, extending or implementing something (either directly or indirectly), or a method call using the direct reference.method()
notation.
Run-time dependency: You need the dependency in your CLASSPATH
to run your artifact. They are produced because you execute code that accesses the dependency (either in a hardcoded way or via reflection or whatever).
Taken from: Compile time vs Run time Dependency - Java however, a much detailed reference is available on Jenkov's website
How the javac compiler does compile-time dependency resolution
It looks at your classpath and sourcepath to find the necessary dependencies.
How the VM does runtime-dependency resolution
The JVM isn't exactly concerned with dependency resolution, AFAIK.
What the JVM does is to load classes from the classpath when they are needed.
For example, when your program (say class A) hits the first time:
// in class A
F x = new F(42);
the class F
will be loaded.
If the class is not found, you get a ClassNotFoundException. If you changed the F class between compilation of A
and execution, and dropped, for example, the F(int)
constructor, then you get several different ugly exceptions.