Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a HeadlessException: No X11 DISPLAY variable was set

Tags:

java

swing

awt

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:159)         at java.awt.Window.<init>(Window.java:432)         at java.awt.Frame.<init>(Frame.java:403)         at javax.swing.JFrame.<init>(JFrame.java:202)         at DrawGUI.<init>(DrawGUI.java:15)         at ShapeCreator.<init>(ShapeCreator.java:31)         at ShapeCreator.main(ShapeCreator.java:138) 

What does this error message mean? And how can I solve it?

like image 314
Ahsan Avatar asked Mar 07 '11 11:03

Ahsan


People also ask

What is X11 display variable?

The DISPLAY environment variable instructs an X client which X server it is to connect to by default. The X display server install itself normally as display number 0 on your local machine. In Putty, the “X display location” box reads localhost:0 by default.

What is X11 display Linux?

The X11 allows taking GUI access over SSH to any of the LINUX or UNIX systems to run any application/program in GUI. There are few things that needs to be taken care of: 1. Make sure the X11Forwarding is enabled in the ssh_config file.

What is Java AWT HeadlessException?

awt. HeadlessException is a runtime exception in Java that occurs when code that is dependent on a keyboard, display or mouse is called in an environment that does not support a keyboard, display or mouse.

How do I export a display variable in Linux?

Go to the file . bashrc in your home directory and set the variable, then export it. you can use /etc/bashrc if you want to do it for all the users.


2 Answers

I assume you're trying to tunnel into some unix box.

Make sure X11 forwarding is enabled in your PuTTY settings.

enter image description here

like image 118
adarshr Avatar answered Oct 14 '22 21:10

adarshr


This appears to be a more general SWING/AWT/JDK problem that just the JBOSS installer:

The accepted answer below solved the issue for me :

Unable to run java gui programs with ubuntu

("sudo apt-get install openjdk-6-jdk")

like image 44
monojohnny Avatar answered Oct 14 '22 20:10

monojohnny