title: How to execute a java .class from the command line
body: <p>I have a compiled java class:</p>
  
  <p><strong>Echo.class</strong></p>
  
  <pre><code>public class Echo {
      public static void main (String arg) {
  
              System.out.println(arg);
      }
  }
  </code></pre>
  
  <p>I <code>cd</code> to the directory and enter: <code>java Echo "hello"</code></p>
  
  <p>I get this error:</p>
  
  <pre><code>C:\Documents and Settings\joe\My Documents\projects\Misc\bin&gt;java Echo "hello"
  Exception in thread "main" java.lang.NoClassDefFoundError: Echo
  Caused by: java.lang.ClassNotFoundException: Echo
          at java.net.URLClassLoader$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClassInternal(Unknown Source)
  Could not find the main class: Echo.  Program will exit.
  </code></pre>
  
  <p>What is the simplest way to get my java code in a form that I can run from the command line as apposed to having to use Eclipse IDE?</p>