Error trying to execute a class

4

This is my first post here on the stack, I'm having trouble running this class on NetBeans. I am using version 1.8.0_40 of Java, I already tried to search for some solution, but I did not find it.

public class Dialog1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        // TODO code application logic here
        JOptionPane.showMessageDialog(null, "Bem Vindo ao Java");
    }

}

When compiling this class it up to as success, but gives an error message

  

run: Error: Could not locate or load main class   dialog1.Dialog1 Java Result: 1 CONSTRUCTED WITH SUCCESS (total time: 1   second)

Does anyone know what might be happening?

    
asked by anonymous 12.03.2015 / 19:33

2 answers

2

It may be missing the import at the beginning of the file:

import javax.swing.JOptionPane;
    
13.03.2015 / 08:38
0

The import of class JOptionPane is missing. As stated by Victor, you can import it with import javax.swing.JOptionPane; at the beginning of the code. But as in that case you're only using it once, it could do like this:

javax.swing.JOptionPane.showMessageDialog(null, "Bem vindo ao java!");

In this case, you are "calling" the class to be used only on this line. If you need it again, you'll have to repeat that command.

    
17.11.2015 / 15:10