0

I'm trying to create an example window with Eclipse WindowBuilder. The code is the following:

import javax.swing.JFrame;
import javax.swing.JLabel;

//import statements
//Check if window closes automatically. Otherwise add suitable code
public class HelloWorldFrame extends JFrame {

    public static void main(String args[]) {
        new HelloWorldFrame();
    }
    HelloWorldFrame() {
        JLabel jlbHelloWorld = new JLabel("Hello World");
        add(jlbHelloWorld);
        this.setSize(100, 100);
        // pack();
        setVisible(true);
    }
}

As I understand, running this code should display a window. Nevertheless, it shows the following error:

Error: Could not find or load main class HelloWorldFrame

Is there anything that should be configured before running the code? I'm using the execution environment JavaSE-1.7 and Eclipse Mars.1 Release (4.5.1) on Ubuntu 64-bits.

--------------------------------------------------------------------------------------------------------------------------------

Update 1

In my Package Explorer I have the following:

Package Explorer

I have checked that the runtime classpath is the same:

enter image description here

Is there anything which is still misconfigurated?

Marco
  • 391
  • 4
  • 18
  • For whatever reason you created the file somewhere that isn't in your class path – user1231232141214124 Feb 25 '16 at 17:44
  • @redFIVE I have updated the post. I have checked the class path but it seems to be the same where the file is created. – Marco Feb 25 '16 at 18:38
  • pretty sure that squiggly yellow line under the class name is going to tell you exactly what is wrong... – user1231232141214124 Feb 25 '16 at 19:25
  • @redFIVE it's a warning which says" The serializable class HelloWorldFrame does not declare a static final serialVersionUID field of type long. Even if I choose to add a serial version ID or to suppress this warning I have the same error. – Marco Feb 25 '16 at 19:34

0 Answers0