-classpath option for javac and java
classpath, java
Solution
Because they are two separate operations and not necessarily the same paths.
The runtime dependencies are often more extensive than the compile time dependencies. For example, many programs will code to interfaces, which limits the compile time dependencies to those interfaces. At runtime, the VM must be able to resolve the implementations of those interfaces, which are not required until they are loaded at runtime.
Problem
I'm confused with the role `-classpath` option plays in both compiling and running a java program. Please help me understand.