0
    Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
        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 java.awt.Frame.<init>(Frame.java:384)
        at sun.applet.AppletViewer.<init>(AppletViewer.java:159)
        at sun.applet.StdAppletViewerFactory.createAppletViewer(AppletViewer.java:100)
        at sun.applet.AppletViewer.parse(AppletViewer.java:1140)
        at sun.applet.AppletViewer.parse(AppletViewer.java:1074)
        at sun.applet.Main.run(Main.java:156)
        at sun.applet.Main.main(Main.java:98)

I am getting the above error on compiling the file - "HelloWorldApplet.html" in command prompt with the command -

appletviewer HelloWorldApplet.html
Ravinder Reddy
  • 23,692
  • 6
  • 52
  • 82
Sumukh Bhandarkar
  • 386
  • 1
  • 5
  • 14

1 Answers1

1

Your command

appletviewer HelloWorldApplet.html

Actually launches the user interface tool Applet Viewer that launches your applet and displays it in a standalone application. You are running the code on a Linux based operating system which uses X11 or X.org as the user-interface service (server).

In order to allow you application to connect to this user-interface service the connection parameters must be present in a shell variable DISPLAY. If you are working on the machine you are trying to execute this command at. Try to execute the following before launching appletviewer.

export DISPLAY=:0.0

This instructs to set the shell variable DISPLAY to the first connected local display.

Related or duplicate to: "No X11 DISPLAY variable" - what does it mean?

Community
  • 1
  • 1
Matthias Steinbauer
  • 1,786
  • 11
  • 24