Application initialization failed: no display name and no $DISPLAY environment variable

cburn32
cburn32 used Ask the Experts™
on
I am trying to launch a program that calls xwindows from command line on a Solaris 10 machine. When I invoke the command I get the following error message:

Application initialization failed: no display name and no $DISPLAY environment variable

Any suggestions??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009

Commented:
If you are running it from a text  console, then it wont work, as it is a graphical program.

You must run it from an X session, or you must set DISPLAY to a valid X / graphical console.

How are you logged in?

Author

Commented:
I am logged in through Xwindows and then I opened a console session within Xwindows and ran the command from the command line.
Top Expert 2009

Commented:
You can try setting it to the console:

export DISPLAY=0.0:0

Then running it, and it should open on the console but only if you have privs on that console.
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Top Expert 2009
Commented:
Did you switch user (su) ? That is a common cause of the problem.

Author

Commented:
Yes I switched to user Root.  When I ran the export DISPLAY command I get the following error:

DISPLAY=0.0:0: is not an identifier


I will try to run the program without doing a SU.
Top Expert 2009

Commented:
Its due to your shell, you are using "sh"

If you use ksh or bash you can do:

export DISPLAY=0.0:0

Which is a shorthand for the older syntax which sh still wants in two commands:

DISPLAY=0.0:0
export DISPLAY


You might consider switching shells too.


Lastly, if you run the app and it cannot connect to that display due to permissions, then the owner of the desktop needs to run:

xhosts +

Author

Commented:
Switching users caused the problem.  I launched the program under the initial username and worked!! Thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial