You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chris Dodunski <Ch...@btw.co.nz> on 2003/03/20 22:13:15 UTC

RE: Can't connect to X11 window server using '0:0' as the value ofthe display and now java.awt.HeadlessException

Hi,

Another common (Java) solution is to install PJA Toolkit:

PJA (Pure Java AWT) Toolkit is a JavaTM library for drawing graphics
developed by eTeks. It is 100% Pure Java and doesn't use any native graphics
resource of the system on which the Java Virtual Machine runs.
java.awt.Graphics methods such as drawLine (), fillOval (), drawString
(),... are implemented in the default JVM with native graphical functions
(except in some cases for Java2D) : That means that drawLine () finally
calls a GDI system function on Windows or X11 function on a X11/UNIX machine
even if the drawing is done in an off-screen image using the class
java.awt.Image. This ensures the best performance for drawing graphics with
Java.
But in a few cases, this default behavior can cause problems that PJA
library improves :

When no X11 Display is available on a UNIX machine (also called headless
environment) or when GDI resources are low on Windows, it is impossible to
compute off-screen images with java.awt.Graphics methods under a JDK version
< 1.4, even if your program doesn't need to display these images. Typically,
this situation happens for servlets returning dynamically generated images
like pies, charts or web counters.
With PJA, you don't need to change your Java programs that you expected to
run : setting java.awt system property to com.eteks.awt.PJAToolkit is the
only required modification to your program with Java 1.1 (see PJA FAQ and
com.eteks.awt.PJAToolkit class documentation for more information).
It is also impossible to compute off-screen images when the Java security
manager forbids access to any Toolkit or the AWT library. In that case you
can although create an instance of com.eteks.awt.PJAImage class which
extends java.awt.Image, and draw into it with graphics methods.
Drawing with native function doesn't give always the exact same results for
each pixel on all platforms. For example, SansSerif font renders differently
on MacOS, Windows and other systems : each letter of this font isn't drawn
the same, and is different if font anti-aliasing is set or not on the
system. On MacOS, circles aren't rendered as specified in Java documentation
: fillArc () and drawArc () don't use the same base ellipse...

Finally, PJA library available under GNU General Public License is supplied
with its Java source files, and is a good exemple for studying :

How pixels are drawn by graphics functions on a computer
(com.eteks.awt.PJAGraphics uses Bresenham algorithms to draw lines and
circles).
How to use the Java paradigm for managing images specified by the
ImageConsumer/ImageProducer/ImageObserver interfaces.
How Java Toolkit works and what it needs to work (which abstract classes and
interfaces to implement).

Regards,

Chris.


-----Original Message-----
From: p niemandt [mailto:maudib@acesurfer.co.za]
Sent: Friday, 21 March 2003 7:18 a.m.
To: Tomcat Users List
Subject: Re: Can't connect to X11 window server using '0:0' as the value
ofthe display and now java.awt.HeadlessException


ok: there is another solution to the headless thing: (I wrote a
graphical servlet that runs on a linux box without X, and had the same
problems: The headless seemed to work, well, kinda, but not to my
liking): So I went the xvfb route: This is a virtual frame buffer to can
install on a linux box that emulates an X session, which then kinda
solves all the graphical problems in one step. You set the xvfb to the
resolution required and just start and forget about it.

Worth I shot, I'd say, and might safe you hours of frustration [It did
me ;-) ].


On Thu, 2003-03-20 at 18:34, Micael wrote:
> You using Linux?  What is your environment?  Anyway, setting the JVM is
the
> way to go if you are using Linux.
>
> At 06:09 PM 3/20/03 +0100, you wrote:
> >Hi,
> >
> >I put System.setProperty("java.awt.headless", "true");
> >in my servlet init method it's ok, but now when I open a Frame,
> >I get the exception HeadlessException:
> >
> >java.awt.HeadlessException
> >    at
> >
java.awt.GraphicsEnvironnement.checkHeadless(GraphicsEnvironement.java:121)
> >    at java.awt.window.<init>(Window.java:226)
> >    at java.awt.Frame.<init>(Frame.java:398)
> >    ...
> >
> >What can I do?
> >
> >Georges
> >
> >
> >
> >Chad Johnson wrote:
> >
> >>If I had to wager a guess you'll need to run tomcat in a 'headless' JVM.
> >>To do that add :
> >>
> >>-Djava.awt.headless=true
> >>
> >>To the :
> >>
> >>CATALINA_OPTS
> >>
> >>environment variable.
> >>
> >>-Chad Johnson
> >>
> >>-----Original Message-----
> >>From: Georges Roux [mailto:georges.roux@pacageek.org] Sent: Tuesday,
> >>March 18, 2003 5:32 PM
> >>To: tomcat-user@jakarta.apache.org
> >>Subject: Can't connect to X11 window server using '0:0' as the value of
> >>the display
> >>
> >>
> >>Hello everybody,
> >>
> >>Hi run Tomcat 4.1.18 Standalone on Linux debian(sid)and use
> >>J2sdk1.4.1_01.
> >>
> >>I have a servlet which manipulate exif informations in jpg images. it
> >>works well but when I try to run it on tomcat it fails (error 500)
> >>
> >>I have the following error:
> >>"Can't connect to X11 window server using '0:0' as the value of the
> >>display"
> >>
> >>What can I do?
> >>
> >>Georges
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >>
> >>
> >
> >--
> >
> >18:54 18:54 connard
> >18:55 18:54 t'as que ca a faire? ;)
> >18:56 18:55 je m'ennuies ferme ouais ! encore 5mn avant la fin du taf,
> >      donc j'en profite pour passer dans les fortunes :)
> >
> >
> >+==========================================+
> >|                                          |
> >|      Georges Roux                        |
> >|  URL : georgesroux.pacageek.org          |
> >|  email : georges.roux@free.fr            |
> >|  mobile : +33 (0) 613977573              |
> >+==========================================+
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
>
>
>
> LEGAL NOTICE
>
> This electronic mail  transmission and any accompanying documents contain
> information belonging to the sender which may be confidential and legally
> privileged.  This information is intended only for the use of the
> individual or entity to whom this electronic mail transmission was sent as
> indicated above. If you are not the intended recipient, any disclosure,
> copying, distribution, or action taken in reliance on the contents of the
> information contained in this transmission is strictly prohibited.  If you
> have received this transmission in error, please delete the message.
Thank
> you
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
--
p niemandt <ma...@acesurfer.co.za>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org