import java.awt.*;
public class GUiJava{
GUiJava(){
Frame fm = new Frame();
Label lb = new Label("Welcome to the First GUI");
fm.add(lb);
fm.setSize(300,300);
fm.setVisible(true);
}
public static void main(String[] args){
GUiJava gu = new GUiJava();
}
}
I am trying to learn Java GUI, but When I try to run the program, I get an error like the one below.
When I use Swing or AWT, I get the same error. I have tried out some possible solutions of setting the Display variable, they don't work.
Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:208)
at java.desktop/java.awt.Window.<init>(Window.java:548)
at java.desktop/java.awt.Frame.<init>(Frame.java:423)
at java.desktop/java.awt.Frame.<init>(Frame.java:388)
at GUiJava.<init>(GUiJava.java:6)
at GUiJava.main(GUiJava.java:14)