title: ClassNotFoundException when running in Command Prompt
body: <p>I am very new to java and tried to run a simple code of calculating volume. The code is below:</p>
  
  <pre><code>package chapter6;
  
  class Box {
  
      double width;
      double height;
      double depth;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package chapter6;
  
      public class BoxDemo {
  
          public static void main(String[] args) {
  
              Box myBox = new Box();
              double vol;
  
              myBox.depth = 1;
              myBox.height = 2;
              myBox.width = 3;
  
              vol = myBox.depth * myBox.height * myBox.width ;        
  
              System.out.println("Volume: " + vol);
          }
  
      }
  </code></pre>
  
  <hr>
  
  <p>I am able to run the code from eclipse, but when i try to run the code in Command Prompt i get the error:</p>
  
  <pre><code>C:\Prabhjot\Java\CompleteRefence\build\classes&gt;java BoxDemo.class
  Exception in thread "main" java.lang.NoClassDefFoundError: BoxDemo/class
  Caused by: java.lang.ClassNotFoundException: BoxDemo.class
          at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
  Could not find the main class: BoxDemo.class.  Program will exit.
  </code></pre>
  
  <p>Please assist.</p>