title: Java: package does not exist
body: <p>I am in the directory: E:\stuff\Java></p>
  
  <p>I created a package A: </p>
  
  <pre><code>package pack;
  
  public class A
  {
      public void methodA(){
          System.out.println("MethodA");
      }
  }
  </code></pre>
  
  <p>To compile I have used the following statement:</p>
  
  <pre><code>javac -d . A.java
  </code></pre>
  
  <p>So a folder with the name pack has been created which contains A.class.
  Then i tried to import this package in another program:</p>
  
  <pre><code>import pack.A;
  
      class B
      {
          public static void main(String[] args){
              A a = new A();
              a.methodA();
          }
      }
  </code></pre>
  
  <p>When i try to compile this code: </p>
  
  <pre><code>javac B.java
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>   B.java:1: error: package pack does not exist
  import pack.A;
             ^
  B.java:6: error: cannot find symbol
                  A a = new A();
                  ^
    symbol:   class A
    location: class B
  B.java:6: error: cannot find symbol
                  A a = new A();
                            ^
    symbol:   class A
    location: class B
  3 errors
  </code></pre>
  
  <p>I don't understand why the code fails to run. My B.java file and pack are in the same folder.</p>
  
  <p>Can someone please explain the error in this code??</p>