File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Graphics object under Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Graphics object under Linux" Watch "Graphics object under Linux" New topic
Author

Graphics object under Linux

Alex Iordache
Ranch Hand

Joined: Mar 13, 2001
Posts: 62
I use a servlet for generating images and I have this problem: under Linux RedHat I cannot obtain a Graphics object to be used for drawing into it because (I think) the system doesn't allow me to do so as long as the X environment isn't running.
What I tried:
myClass extends Canvas{
.... Graphics g = this.createImage(w,h).getGraphics()
}
and:
...Graphics g = this.getToolkit().createImage(w,h).getGraphics()
Any suggestions ?
Thanks a lot.
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI Alex,
Yes. I had the same problem with SuSE Linux: No Graphics unless the X environment is running.
It makes perfect sense I thought.

Bye,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

X provides the graphics support environment such as fonts, metrics and other hardware-dependent stuff. Java doesn't support the situation where pure bitmap operations are done without reference to a graphics environment.
For all I know there might be something out there that does the same thing as having X running, but I don't know of one, and it's probably safer to just use X, since the installed user base is larger.


Customer surveys are for companies who didn't pay proper attention to begin with.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Originally posted by Tim Holloway:
X provides the graphics support environment such as fonts, metrics and other hardware-dependent stuff. Java doesn't support the situation where pure bitmap operations are done without reference to a graphics environment.
For all I know there might be something out there that does the same thing as having X running, but I don't know of one, and it's probably safer to just use X, since the installed user base is larger.

The real pain is that X needs to be started BEFORE your appserver starts doing graphics. This may require tweaking task start order.
Alex Iordache
Ranch Hand

Joined: Mar 13, 2001
Posts: 62
Thanks all. I found the answer:
1.There is a pseudo Xserver which should be started first or,
2.A package named 'PJA Toolkit' does exaclty what I need: replace awt.Image package with theirs and is under GNU License.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Graphics object under Linux