Run JFreeChart in a Web Server

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
aerich

Run JFreeChart in a Web Server

Post by aerich » Sat Sep 03, 2005 6:30 am

Can someone help !? I have created code to generate JFreeChart charts for a while now, using custom code in a standalone application - fantastic results - then I embed the chart images into a pdf using a pdf library.

Now, I need to run the same java code (very complex) in a servlet and generate *exactly* the same chart images - but i suddenly find that JFreeChart charts need the "AWT" to generate images into a "BufferedImage" object, and the "imageio" library to export to a "PNG" - none of this AWT stuff runs in a web server, so how can I create the chart *without* the "awt" (the code is custom, intricate, and complex and must run inside a servlet - *cannot* use "cewolf") ??? Can anyone help?

jmoors
Posts: 7
Joined: Fri Jul 29, 2005 11:29 am

Post by jmoors » Sat Sep 03, 2005 9:08 pm

I don't see why you can't use awt in the web server, if you use a BufferedImage, then you can encode as JPEG/ PNG and put on the response output stream.

If your using Unix/Linux then you'll need set the headless parameter i.e for tomcat set the property via :-

export CATALINA_OPTS="-Djava.awt.headless=true"'.

I've used a similar process in the past.

Jason.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Sep 05, 2005 11:25 am

This is a general issue with the way Sun has implemented Java on Unix-like systems. See item 10 in the FAQ:

http://www.jfree.org/phpBB2/viewtopic.php?t=8420
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked