class helloWorld{ public static void main(Stirng [] s){ JOptionPane.showMessageDialog(null, "Hello World!", "Alert", JOptionPane.INFORMATION_MESSAGE); } }
根据这个继续出现这样的错误:hello.java:6: cannot resolve symbol symbol : variable JOptionPane location: class helloWorld JOptionPane.INFORMATION_MESSAGE); ^ hello.java:3: cannot resolve symbol symbol : variable JOptionPane location: class helloWorld JOptionPane.showMessageDialog(null, ^ 2 errors
上面那个代码你要导入Swing包的,要不怎么可能有那个类
文件头加句 import javax.swing.*;
import javax.swing.*;public class helloWorld{ public static void main(Stirng [] s){ JOptionPane.showMessageDialog(null, "Hello World!", "Alert", JOptionPane.INFORMATION_MESSAGE); } }
helloWorld.java import javax.swing.*;public class helloWorld{ public static void main ( String args[] ) { JOptionPane.showMessageDialog(null, "Hello World!", "Alert", JOptionPane.INFORMATION_MESSAGE); } } 完整的是这样吧,但是还是出现同样的错误
你的JAVA_HOME怎么设的?我想可能是classpath的问题。
那就不要图形界面了helloWorld.java //import javax.swing.*;public class helloWorld{ public static void main ( String args[] ) { System.out.println("hello world!"); } }
public static void main(Stirng [] s){
JOptionPane.showMessageDialog(null,
"Hello World!",
"Alert",
JOptionPane.INFORMATION_MESSAGE);
}
}
symbol : variable JOptionPane
location: class helloWorld
JOptionPane.INFORMATION_MESSAGE);
^
hello.java:3: cannot resolve symbol
symbol : variable JOptionPane
location: class helloWorld
JOptionPane.showMessageDialog(null,
^
2 errors
public static void main(Stirng [] s){
JOptionPane.showMessageDialog(null,
"Hello World!",
"Alert",
JOptionPane.INFORMATION_MESSAGE);
}
}
import javax.swing.*;public class helloWorld{
public static void main ( String args[] ) {
JOptionPane.showMessageDialog(null,
"Hello World!",
"Alert",
JOptionPane.INFORMATION_MESSAGE);
}
}
完整的是这样吧,但是还是出现同样的错误
//import javax.swing.*;public class helloWorld{
public static void main ( String args[] ) {
System.out.println("hello world!"); }
}