I am new to swing development using eclipse but I have been using eclipse for my java code development for more than a year. Today when I wrote a sample swing class got a curious error from eclipse.
I created a workspace swing , and created a new project in the same name as the workspace. Then wrote a sample class inside the project, please find the code below.
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class SwingDemo {
public SwingDemo() {
// TODO Auto-generated constructor stub
JFrame jFrame = new JFrame("A sample swing application");
jFrame.setSize(275, 100);
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel jLabel = new JLabel("Welcome to swing!!!!");
jFrame.add(jLabel);
jFrame.setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
new SwingDemo();
}
});
}
}
When I tried to execute it in eclipse ,resulted in the below error
The project: swing which is referenced by the classpath, does not exist.
The same code was executed fine, when the project name and workspace name were differrent.
I am just curious, what caused this error. Please help