aspose file tools*
The moose likes Other Open Source Projects and the fly likes Jasper Report: Can't connect to X11 window server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jasper Report: Can Watch "Jasper Report: Can New topic
Author

Jasper Report: Can't connect to X11 window server

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874


The application is developed and deployed on windows machine and working like champ. But now I deployed the app on linux server (Kernel version: 2.4.21-20.ELsmp GNU/Linux) and facing this error.

Anybody help please. Thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You will need to run the JVM in headless mode if you want to use any of the AWT or Swing components.
[ March 17, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Trying it out.
Thanks Ben.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Any Luck?
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
No. Actually haven't tried it out, my project manager changed the priorities and assigned me some other work. Will return to this, may be after a week.

Thanks.
Jeff Taillon
Greenhorn

Joined: Apr 08, 2005
Posts: 1
Adding the -Djava.awt.headless=true to my JVM solved the problem for me.

Thanks a lot.

Jeff
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
But I still get an Exception:

java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.ja va:62)

Save me!!!
Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
Adeel,
In the .profile add this statement "DISPLAY=:0.0"
Then execute the .profile and try again. This is what I did and the issue got resolved. Also make sure you have the X11 package installed in linux.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Sripathi Krishnamurthy:
In the .profile add this statement "DISPLAY=:0.0"
Then execute the .profile and try again. This is what I did and the issue got resolved. Also make sure you have the X11 package installed in linux.


Pardon me, Sripathy.
Could you please explain .profile a bit?
Dont know about X11 package. Is it same as XFree86??

[Edited]
Oh! I forgot to thank you.
Thanks mate.
[ April 18, 2005: Message edited by: Adeel Ansari ]
Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
Originally posted by Adeel Ansari:


Pardon me, Sripathy.
Could you please explain .profile a bit?
Dont know about X11 package. Is it same as XFree86??

[Edited]
Oh! I forgot to thank you.
Thanks mate.

[ April 18, 2005: Message edited by: Adeel Ansari ]


I am not an unix expert. But I can try my best to explain what .profile means. Whenever you login to unix, you will reach your home directory. It can be /home/adeel. You can give "cd ~" in unix which will take you to your home directory. In this directory you can create(if one does not exist) a file called .profile . you can give a set of commands in this .profile . Whenever you login, the commands of the .profile will be executed. So it is like first time initialization of all the required commands can be dumped in .profile. You have to give execute permission for .profile to be executed.

A sample .profile can be like,

#-----------------------------------------------#
# A sample .profile file #
#-----------------------------------------------#
# Courtesy of Developer's Daily #
# http://www.DevDaily.com #
#-----------------------------------------------#

PATH=$PATH:/usr/local/bin:/usr/gnu/bin:.

set -o vi # enable the ability to recall previous commands with

PS1='$PWD> ' # set the prompt to display the current directory

#----------------------------#
# a few Korn shell aliases #
#----------------------------#

alias nu="who|wc -l" # nu - number of users
alias np="ps -ef|wc -l" # np - number of processes running
alias p="ps -ef"

# mimick a few DOS commands with these aliases:

alias cd..="cd ../.."
alias cd...="cd ../../.."
alias dir="ls -al"
alias edit=vi
alias help=man
alias path="echo $PATH"

X11, also known as x-windows is needed to view graphic images and windows. I am not sure if x-windows and xfree86 are same.

Hope this helps.
Thanks and cheers
Sripathi
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
From the first line of my first post on this topic which was

"java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable."

As Sripathy said about setting DISPLAY:0.0 into .profile, this error message is already addressing the same problem. I figured out that X-windows is not there. What you people say?

Thanks Sripathy for your efforts.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

hi adeel,

last night I had posted on this thread but thread is lost due to saloon's dis crash !!
I dont have too much idea of your problem but I was wondering if still you have tried Ben's suggestion of running JVM in headless mode.
because "Can't connect to X11 window server" error may be due if you are not running in headless mode or It may be one reason as you said in one of post that might be threr is no X11 server. I have found this on net.



What causes the error "Can't connect to X11 window server"?
The Sun AWT classes on Unix and Linux have a dependence on the X Window System: when you use the classes, they expect to load X client libraries and be able to talk to an X display server. This makes sense if your client has a GUI... unfortunately, it's required even if your client uses AWT but does not have a GUI. For example, you need access to an X server to use the java.awt.BufferedImage class.

Access to an X display server means a few things:

* An X display server is running somewhere.
* The environment in which you run Java includes an environment variable DISPLAY identifying how to reach the server.
* There are no security settings in the server to prevent your client from opening a connection.

In general, if you're running your program from a terminal within the X Window System, all these things are true and the program just works. If you can run other X applications, like xterm or xclock, you should be able to run your Java AWT application.

In non-graphical environments, such as a servlet engine, your program may not know how to find or connect to an X display server. A common solution here is to run a special non-display version of the X display server, Xvfb, and set DISPLAY to point to it.

New information for JDK1.4: JDK1.4 evidently includes a new property that will allow the AWT to run in a headless (without a display) environment. This setting is supposed to solve the problem: java.awt.headless=true



Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
 
jQuery in Action, 2nd edition
 
subject: Jasper Report: Can't connect to X11 window server