title: What is the effect of the dot (.) in the Java classpath?
body: <p>This is an example question from "SCJP mock exam":</p>
  
  <blockquote>
    <p>Given the default classpath:</p>
    
    <p>/foo</p>
    
    <p>And this directory structure:</p>
  
  <pre><code>foo
    |
   test
      |
     xcom
       |--A.class
       |--B.java
  </code></pre>
    
    <p>And these two files:</p>
  
  <pre><code>package xcom;
  public class A { }
  package xcom;
  public class B extends A { }
  </code></pre>
    
    <p>Which allows B.java to compile? (Choose all that apply.)</p>
    
    <p>A. Set the current directory to <code>xcom</code> then invoke</p>
  
  <pre><code>javac B.java
  </code></pre>
    
    <p>B. Set the current directory to <code>xcom</code> then invoke</p>
  
  <pre><code>javac -classpath . B.java
  </code></pre>
    
    <p>C. Set the current directory to test then invoke</p>
  
  <pre><code>javac -classpath . xcom/B.java
  </code></pre>
    
    <p>D. Set the current directory to test then invoke</p>
  
  <pre><code>javac -classpath xcom B.java
  </code></pre>
    
    <p>E. Set the current directory to test then invoke</p>
  
  <pre><code>javac -classpath xcom:. B.java
  </code></pre>
  </blockquote>
  
  <p>The answer is C, I don't understand the use of the operator <code>.</code> there. Please explain.</p>
  
  <p>The book says:</p>
  
  <blockquote>
    <p>In order for <code>B.java</code> to compile, the compiler first needs to be able to find <code>B.java</code>.
    Once it's found <code>B.java</code>, it needs to find <code>A.class</code>. <strong>Because <code>A.class</code> is in the
    <code>xcom</code> package the compiler won't find <code>A.class</code></strong> if it's invoked from the <code>xcom</code> directory.
    Remember that the <code>-classpath</code> isn't looking for <code>B.java</code>, it's looking for whatever classes
    <code>B.java</code> needs (in this case <code>A.class</code>).</p>
  </blockquote>
  
  <p>I don't get this, if both files are on the same package, why wouldn't the compiler find A? </p>