Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display variable on unix

pramod karnani
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When I tried to run runme.jar file on unix , I am getting this exception

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(
at java.awt.Window.<init>(
at java.awt.Frame.<init>(
at javax.swing.JFrame.<init>(
at suncertify.gui.MainWindow.<init>(
at suncertify.gui.ApplicationRunner.<init>(
at suncertify.gui.ApplicationRunner.main(

How to solve this , how to set display variable X11 DISPLAY on unix?

Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 11972
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to move this to the Unix / Linux forum, since this is only tangentially related to the SCJD assignment.

Are you working on the physical Unix machine? That is, can you confirm that you are not telnetting in, or otherwise connecting remotely?

Are you running a graphical user interface on the Unix system? Under Unix this should be the X11 Window System (often called X11 or X). Many Unix and (most) Linux systems have a desktop environment running on top of the X11 Window System - typically Gnome or KDE. Are any of these sounding familiar?

If the answers to both questions are yes (yes - you are running on the physical Unix system; and yes - you are running a graphical user interface), then you may be able to enter into your xTerm the command "export DISPLAY=:0.0" (without the quotes).

If you are not physically attached to the Unix system, then you will need to provide a little more information before we can provide any more help.

If you are not running a graphical user interface on the Unix system, then there are ways around it, but they may be more trouble than they are worth.

Finally - for the SCJD project, you don't really need to test under Unix systems (although I applaud you for trying). One option you might want to consider is getting a live CD so you can run Linux on your own personal computer without actually installing Linux. You could then use this for testing.

Regards, Andrew
Tim Holloway
Saloon Keeper
Posts: 18319
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is most commonly seen when you have a web application that does graphics (such as charting) and you're running it on a server that isn't running a windowing system.

You can also encounter it if you attempt to run a Swing or AWT app on a command-line (non-windowed) machine.

DISPLAY is automatically set when you're running in a windowed session. You'd normally not change it.

For a webapp, there's an option to run "headless", but I don't have the documentation handy and I think it varies with whatever web application server you're using. Google will help - just look for "headless" and the name of your appserver (Tomcat or whatever).

For a standalone app, that's not going to work, since presumably the app depends on a GUI to work at all. In that case, you need to actually be running a windowing system. This might require installing the GUI and desktop packages, if they're not already installed.
t tram
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question leaves out some important details. Are you telnetting in, or ssh into the unix machine froma Windows machine? That seems like the most common things that people would do. If that is the case and assuming that your unix server is already running the X Server, you will need a X windows manager on your Windows machine. One free one is Xming that you can download off the net. You will need to just google for it. Then download putty to be used with Xming. You will need to enable the X11 forwarding in the connection properties of putty.

If you use some other ssh clients, you might have to set up the DISPLAY environments differently.
For c-shell, you would use something like:
setenv DISPLAY

for bash:
export DISPLAY

Just remember to change the ip address to your unix machine.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic