Linux exception

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
TD

Linux exception

Post by TD » Wed Aug 02, 2000 6:48 am

I'm getting this exception on Linux:
java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment

I remember reading somewhere about how to avoid this, but now I can't find it. I've looked in the PDF, and the web site. What am I missing to be able to deploy on linux? This has something to do with X and fonts, but I don't remember how to fix it.

Thx.

David Gilbert

RE: Linux exception

Post by David Gilbert » Wed Aug 02, 2000 8:54 am

Are you using JFreeChart to develop a Java servlet? I remember reading something in the Java newsgroups about problems deploying "graphical" Java servlets on servers that don't have X running - I think AWT requires X for various things even if you aren't displaying anything directly on the machine (as is the case with servlets), although I don't know the details.

I'd suggest doing a search on Deja (http://www.deja.com/usenet) for information...unless someone else can help out here.

Regards,

DG.

TD

RE: Linux exception

Post by TD » Wed Aug 02, 2000 11:34 pm

Yes, I'm using JFreeChart to develop a Java servlet, and the server is not running X. I thought I had read something about it here, but it might have been in Jason Hunter's servlet book (O'Reilly). I'll check that tonight.

TD

RE: Linux exception

Post by TD » Thu Aug 03, 2000 10:31 pm

Looks like I get to be the bearer of bad news. Here's the deal...

Since you are using AWT classes to draw the charts, and AWT relies on a display driver for buffering (and therefore speed), the VM throws an exception when the display driver cannot be accessed.

The "correct" solution is to not use AWT classes, and to use one of the graphics libraries instead (like JIMI, or whatever it's called). In the event that you are not willing to consider doing this, there are a couple solutions.

OPTION #1
Replace the AWT classes with PJA ("Pure Java AWT Toolkit") from Eteks. This open source, pure AWT replacement does not rely on system hardware. This is your only option if you do not have control over your unix environment, or you are deploying on any non-unix platform without a display driver -- like an embedded system based on Dallas Semiconductors TINI. The problem with this is that space constrained environment like TINI takes a serious hit any time you add another library.

http://www.eteks.com


OPTION #2
On Unix, the X Virtual Frame Buffer can be used. It is a full X server which doesn't open any devices (the output can be a memory-mapped file) but which otherwise behaves as an X display. It is also useful for testing. The Xvfb is part of the X11R6 distribution, in programs/Xserver; set the configuration option in config/{machine}.cf to build the distribution with this server.

The KLGroup's JClass J<no-so-free>Chart has the same problem. Their suggestion as far as graphics cardless servers seems to be to use the virtual frame buffer option in X11R6. The following is a link to more information.

http://services.klgroup.com/support/sea ... _pr_26.htm

Post Reply