title: How does javac automatically compile dependencies of a class
body: <p>Given the following directory structure:</p>
  
  <pre><code>/top
     |--- wrk
            |--- pkg
                    |--- A.java
                    |--- B.java
  </code></pre>
  
  <p>Assume that the two files <code>A.java</code> and <code>B.java</code> contain the following code, respectively:</p>
  
  <pre><code>// Filename: A.java
  package pkg;
  class A { B b; }
  
  // Filename: B.java
  package pkg;
  class B {...}
  </code></pre>
  
  <p>Assuming that the current directory is <code>/top/wrk</code></p>
  
  <p>Why does the command <code>javac -cp . pkg/A.java</code> work successfully even though we have not yet compiled <code>B.java</code>?</p>
  
  <p>Also if the current directory is <code>/top/wrk/pkg</code> then the command <code>javac A.java</code> works. How so? </p>