I am studying and doing a test with Java. Technically I should get a little window with a Hello World (and the rest of the text that I have put) but nothing comes out.
The IDE does not give me an error and I do not see the error anywhere, nor do I know what I am missing.
Any suggestion? The code is the following:
import javax.swing.JFrame;
import javax.swing.JLabel;
import sun.applet.Main;
/**
*
* @author
*/
public class main extends JFrame {
public main() {
JLabel lblSaludo = new JLabel("Hola Mundo. Creando mi primer ejemplo");
add(lblSaludo);
this.setSize(400,200);
this.setTitle("JFrame");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
Main main = new Main();
}
}
Thank you very much, greetings.
First of all, you are creating an instance of a different class than the one you created, since in the method
main
you have:But your class is called main, without capital letters so it should be
Remember that Java is quite picky when it comes to case.