I am learning GUI in Java, and for that I have created a demo program:
import java.awt.*;
public class FrameDemo extends Frame {
public FrameDemo(){
super("Frame Demo");
setSize(200, 200);
setVisible(true);
}
public static void main(String args[]){
new FrameDemo();
}
}
It was compiled successfully. But when I tried to execute the program, I found the following error:
Exception in thread "main" java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:173)
at java.awt.Window.<init>(Window.java:437)
at java.awt.Frame.<init>(Frame.java:419)
at FrameDemo.<init>(FrameDemo.java:4)
at FrameDemo.main(FrameDemo.java:9)
I am using Xubuntu 10.10 and java -version
gives:
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1)
OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)
What should I to do?
One more thing: It is the same sort of error I got when I tried to execute Dr. Java and HJSplit's jar file.