title: In Java: Could not find the main class
body: <p>When I wrote a standalone client and tried to execute it, 
  it's giving me the following errors:</p>
  
  <p>Running in Windows:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: TestClient
  Caused by: java.lang.ClassNotFoundException: TestClient
          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)
  Could not find the main class: TestClient.  Program will exit.
  </code></pre>
  
  <p>This is in Linux</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: TestClient (wrong name: com/tata/bayer/service/TestClient)
          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:301)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
  Could not find the main class: TestClient.  Program will exit.
  </code></pre>
  
  <p>Now i am getting </p>
  
  <pre><code>C:\Softwares\apache-tomcat-6.0.33\webapps\tkweb-ws-12.0\WEB-INF\classes\com&gt;java com.tata.bayer.service.TestClient
  Exception in thread "main" java.lang.NoClassDefFoundError: com/tata/bayer/service/TestClient
  Caused by: java.lang.ClassNotFoundException: com.tata.bayer.service.TestClient
          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)
  Could not find the main class: com.tata.bayer.service.TestClient  Program will exit.
  </code></pre>