Asked By
Nichole W
0 points
N/A
Posted on - 10/16/2011
Here's my 7-line code, supposedly making a dialog box saying "It worked!":
import javax.swing.*;
class MyFirstProgram {
public static void main(String[] arg) {
JOptionPane.showMessageDialogue;(nul… "It works!");
System.exit(0);
}
}
I get this error when trying to compile it using javac:
hello.java:4: error: cannot find symbol
JOptionpane.showMessageDialogue((null)…
(the arrow..) ^
I'm writing the code exactly how my textbook tells me, so why is this happening and how can I fix it?
Answered By
metex
5 points
N/A
#92637
Why this Java error occurred?
Hello,
You can fix it easily. You have wrong method name and an extra semicolon as well.
It should be
JOptionPane.showMessageDialog( null,"It works");
Hope this will help.
Good Luck.
Answered By
daistarz
0 points
N/A
#92638
Why this Java error occurred?
The error occurs because you have used a wrong method and wrong syntax along the line containing JOptionpane. You have written Dialog instead of Dialog and there should be no semi colon after Dialog.
The brackets part should contain (null,"It works!").
Please try the following code.
import javax.swing.*;
public class MyFirstProgram {
public static void main(String[] arg) {
JOptionPane.showMessageDialog(null,"It works!");
System.exit(0);
}
}
Thank you.
  Â