title: cannot access class in the same package without adding to classpath
body: <p>Project structure:</p>
  
  <pre><code>./src/com/example/Test.java
  ./src/com/example/Dog.java
  </code></pre>
  
  <p>Test.java</p>
  
  <pre><code>package com.example;
  
  public class Test {
      public void testing() {
          Dog d = new Dog("Lab");
      }
  
  }
  </code></pre>
  
  <p>Dog.java</p>
  
  <pre><code>package com.example;
  
  public class Dog {
      private String breed;
  
      Dog(String breed) {
          this.breed = breed;
      }
  }
  </code></pre>
  
  <p>It compiles successfully when I try this</p>
  
  <p><code>.\src &gt; javac com\example\Test.java</code></p>
  
  <p>But it fails when I do this</p>
  
  <p><code>.\src &gt; javac -cp "C:\Tomcat\lib\servlet-api.jar" com\example\Test.java</code></p>
  
  <p>With this error</p>
  
  <pre><code>error: cannot find symbol
                  Dog d = new Dog("Lab");
                  ^
    symbol:   class Dog
    location: class Test
  </code></pre>
  
  <p>I'm guessing it's because the existing classpath is overwritten. How do I avoid that?</p>
  
  <p>Also, can you explain more on detail why it fails when it is run from the parent directory of \src, like this</p>
  
  <p><code>javac src\com\example\Test.java</code></p>
  
  <p>I get the same error as the one with classpath.</p>
  
  <p>Sorry for all the confusion.</p>
  
  <p>Thank you Jon Skeet for helping out.</p>