ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Exception in thread "main" 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>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)
at java.awt.image.BufferedImage.createGraphics(Unknown Source)
at (my code)
at (my code)
at (my code)
The line code that throws this exception is either
Graphics2D g = (Graphics2D)b.getGraphics();
Graphics2D g = b.createGraphics();
I have a linux box on which I would like to generate some images for use on a website, it doesn't have a X server - because a) it is only a P100 with a 1Gb HD, so the space required, and the processing power required for the X server are lacking! and b) the only cables out of the box are power and network... i.e. no moniter/k-b/etc
it is running Suns JVM on a debian base.
how can I resolve this issue - other than killing my machine with an X-server
I am not even close to a java expert. In fact, I haven't written a line of Java since I was forced to in a CS class in college back in 2000. But I looked through the awt functions and a lot of them having rendering sub functions and it is possible some initializer or something is trying to interact with X somehow. This wouldn't be a problem in windows because the gui interface is always there to interact with in windows.
Well, again, I could easily be talking out of my pinky toe or something here.... but is there no way to manipulate an image file with something that isn't a member of the Abstract Windows Toolkit? I mean, if all you want to do is write images to a file it seams kind of silly to have all that class structure for a graphical interface included. There must be some file IO commands outside of the scope of AWT.
Originally posted by jtshaw There must be some file IO commands outside of the scope of AWT.
Originally posted by Cand1e is there a way round it?
Originally posted by Cand1e how can I resolve this issue
I've been reading the API and *I* havn't found anything yet, but I'll keep searching and this was part of my search, asking here.
there are FILE IO commands out of the scope, i.e. I can read files and write files, I can probably read and write image files, but the problem is image manipulation, getting hold of a Graphics[2D] object so I can call Graphics.draw(Shape s)); before writing the image back to file.
You can use XVFB (the X Virtual Framebuffer) to use AWT on headless *NIX boxen... it is installed with X on most distros. This is the code I use to start XVFB on my server for an on-the-fly thumbnail application:
This starts a 1x1 virtual X screen (you can write off the edges of the screen so you might as well take up as little memory as possible imho) at 24 bpp. Then when you start your java application, you have to run it like this:
I just thought, you could also either use JDK1.4 which has headless AWT support built-in (I believe you just pass something like java -Djava.awt.headless=1), or you could try PJA (http://www.eteks.com/pja/en/) which is a third party library for headless AWT operations.
From my experience with headless AWT, my first post is the easiest to implement, and stays true to standard java libraries. I haven't played with the 1.4 headless options.