title: error: could not find or load main class <class Name>
body: <pre><code>package demo;
  import java.io.*;
  class A
  {
      public void run()
      {
          System.out.println("This Is Class A : public void run()");
      }
  }
  class B
  {
      public static void main(String args[])
      {
          System.out.println("Main Method Executed");
          A obj1 = new A();
          obj1.run();
      }
  }
  </code></pre>
  
  <p>Compile :</p>
  
  <pre><code>d:\java&gt;javac -d . demo.java
  </code></pre>
  
  <p>---> class file be created in directory demo [ A.class, B.class]</p>
  
  <pre><code>Run : d:\java&gt;java B
  Error: could not find or load main class B
  </code></pre>
  
  <p>but if I remove the line 1 [package demo;] than it run proper.
  so, when we use package name than why "Error: could not find or load main class B" error be generated.</p>