I’ve just started learning Java as part of a college course and this is the first time I have posted in the Java section here on SPF. My OS is Windows XP and I’m using NetBeans IDE 7.0.1 for writing and running Java.
I’ve tried to run the program below in NetBeans, but it gives me an error message.
import javax.swing.JOptionPane;
public class WelcomeInMessageDialogBox {
public static void main(String[] args) {
// Dialog Box
JOptionPane.showMessageDialog(null, "Welcome to Java");
}
}
Is there an error in the program or do I need to run the code in a different way in order to make it work?
The error message I receive is as follows;
run:
java.lang.NoClassDefFoundError: welcomeinmessagedialogbox/WelcomeInMessageDialogBox
Caused by: java.lang.ClassNotFoundException: welcomeinmessagedialogbox.WelcomeInMessageDialogBox
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: welcomeinmessagedialogbox.WelcomeInMessageDialogBox. Program will exit.
Exception in thread “main” Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Thanks!