Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linux Graphics problem

14 views
Skip to first unread message

Mike D

unread,
Feb 8, 2002, 12:37:20 PM2/8/02
to
Hello there,

I would like to create an Image, get its graphics context and then draw on
it.

I created a test program with just 2 lines...

BufferedImage buffy = new BufferedImage(1, 1,
BufferedImage.TYPE_BYTE_INDEXED );
Graphics2D = buffy.createGraphics();

This runs fine on my Windows machine but I need it to run on Linux
at which point it throws this...

java.lang.InternalError: Can't connect to X11 window server using ':0.0' as
the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at
sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:58)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment
.java:58)
at
java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1011)

Any ideas on why it doesn't work ? Is there another way of getting
an Image and its Graphics context ?

thanks,

Mike


Mark McKay

unread,
Feb 9, 2002, 1:18:12 AM2/9/02
to
Have you tried using buffy.getGraphics() instead of createGraphics()?

Also, is XWindows set up properly?

Mark McKay

--
We, in all humidity, are the people of currant times. This
concept grinds our critical, seething minds to a halt.
- Anders Henriksson, "A History of the Past, Part II"
(An essay from errors in student papers)

Gordon Beaton

unread,
Feb 9, 2002, 2:28:11 AM2/9/02
to
On Fri, 8 Feb 2002 17:37:20 -0000, Mike D wrote:
> This runs fine on my Windows machine but I need it to run on Linux
> at which point it throws this...
>
> java.lang.InternalError: Can't connect to X11 window server using
> ':0.0' as the value of the DISPLAY variable.

The program is trying to connect to your X server but can't for one of
the following reasons:

- The DISPLAY environment setting ":0.0" is wrong. Are you
running the program on the same machine where X is running or are
you logged in remotely? Set DISPLAY to the name of your X host and
display number before running the program:
export DISPLAY=myhost:0.0

- Are you authorized to connect to the X server? This could be the
problem if you are running the program as a different user than the
one who "owns" the display at the moment. This could also be the
case if you get this error when running the program on a remote host
with the correct DISPLAY setting (not ":0.0". Use xauth to give the
appropriate permissions to the user (read the man page).

- Are you running X at all? If not, then DISPLAY really shouldn't even
be set. If your program needs to connect to an X server but you are
running it in a non-graphical environment, you can use Xvfb to give
the program a (virtual) display to connect to (i.e. without a screen).

I can't tell from here which it is.

/gordon

--
[ do not send me private copies of your followups ]
g o r d o n . b e a t o n @ e r i c s s o n . c o m

Faulty

unread,
Feb 12, 2002, 8:00:49 PM2/12/02
to
Hi somewhere I read something about a new "headless" java release.
As I understand it, it doesnt need XWindows.
Worth a look... just search for headless java on sun site.


"Mike D" <oe...@yahoo.com> wrote in message news:ass*0m...@relay.lsl.co.uk...

Mike D

unread,
Feb 14, 2002, 4:16:37 AM2/14/02
to
Thanks guys.

Just running Xvfb did the job.

Along the way I also came across something called PJA (Pure Java AWT)
which others may find useful - see http://www.eteks.com/pja/en/

I think this may be a similar solution to the 'headless java' that Faulty
mentioned.

0 new messages