title: Error in running java program: java.lang.NoClassDefFoundError
body: <p>I have the following package structure where im trying to run a sample hibernate app</p>
  
  <p>Source files: <code>/home/chander/workspace/HibernateApp/src/com/hib/TranslateSQL.java</code></p>
  
  <p>My current directory:</p>
  
  <pre><code>/home/chander/workspace/HibernateApp/src
  </code></pre>
  
  <p>Compile:
  <code>$JAVA_HOME/bin/javac com/hib/*.java</code>  --- This ran successfully</p>
  
  <p>Run:
  <code>$JAVA_HOME/bin/java com/hib/TranslateSQL</code>  Giving the following exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: TranslateSQL (wrong name: com/hib/TranslateSQL)
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
      at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:315)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
  Could not find the main class: TranslateSQL.  Program will exit.
  </code></pre>
  
  <p>I have my classpath and JAVA_HOME set. I dont seem to find what is wrong with my command.</p>
  
  <p>Also tried the following command:</p>
  
  <pre><code>$JAVA_HOME/bin/java com.hib.TranslateSQL
  </code></pre>
  
  <p>Got the following exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: com/hib/TranslateSQL
  Caused by: java.lang.ClassNotFoundException: com.hib.TranslateSQL
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:315)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
  Could not find the main class: com.hib.TranslateSQL.  Program will exit.
  </code></pre>