title: Eclipse cannot find main class
body: <p>I'm using Eclipse 3.7.2 on Ubuntu 12.04 with OpenJDk 7 installed</p>
  
  <p>java -version gives</p>
  
  <pre><code>java version "1.6.0_24"
  OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu3)
  OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
  </code></pre>
  
  <p>And whenever I try to run a  project, I'm getting the following error.</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: test/Example
  Caused by: java.lang.ClassNotFoundException: test.Example
      at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
  Could not find the main class: test.Example. Program will exit.
  </code></pre>
  
  <p>This happens for all the projects, which I have compiled successfully on my Windows system.
  And, when using the javac and java directly from the terminal, it works. 
  Is there an easy solution? Is this because of OpenJDK? </p>
  
  <p>The class code is :</p>
  
  <pre><code>package test;
  import javax.swing.JFrame;
  import javax.swing.SwingUtilities;
  
  public class Example extends JFrame {
  
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
  
      public Example() {
         setTitle("Simple example");
         setSize(300, 200);
         setLocationRelativeTo(null);
         setDefaultCloseOperation(EXIT_ON_CLOSE);
      }
  
      public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
              public void run() {
                  Example ex = new Example();
                  ex.setVisible(true);
              }
          });
      }
  }
  </code></pre>
  
  <p>UPDATE: My source is in a folder called swingtest. While debugging, I found that Eclipse is using the classpath of the source as swingtest/swingtest/src/test/ rather than swingtest/src/test/ . Can this be corrected?</p>