java.lang.NoClassDefFoundError-GraphicsEnvironment.java

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

java.lang.NoClassDefFoundError-GraphicsEnvironment.java

Post by Heather Grace » Tue Feb 19, 2002 8:46 pm

On Windows 2000, the JFreechart works fine. When I try to access the fonts under Red Hat Linux, 6.2, I get the following error:

java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:58)


Even just trying to list the fonts as follows:

GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontNames = env.getAvailableFontFamilyNames();
out.println("Available Fonts:");
for(int i=0; i<fontNames.length; i++)
out.println(" " + fontNames);


Am I missing something in my classpath or path that the AWT needs?

thanks,

--heather grace

jim

Re: java.lang.NoClassDefFoundError-GraphicsEnvironment.java

Post by jim » Thu Feb 21, 2002 2:43 am

Hi,
It looks like you don't have an X server running. If you have x running, the user JFreeChart is running under might not have permission to connect. try 'man xhost' to see how to set the permissions properly

Robert

Re: java.lang.NoClassDefFoundError-GraphicsEnvironment.java

Post by Robert » Mon Feb 25, 2002 11:19 am

Hi,

I have the same problem under Solaris. Our system admin told me that
the X server has been disabled in order of security things.

Is there another way to let jFreeChart do his job ?

I have to call a servlet running on that server which should build the dataset, draw the chart on "graphics2D" and save this to a jpeg. All this
works fine while working on a form which runs on my WIn 2000 machine.

But on the Solaris machine...as said: NoClassDefFoundError

Thank you for every help.

David Gilbert

Re: java.lang.NoClassDefFoundError-GraphicsEnvironment.java

Post by David Gilbert » Mon Feb 25, 2002 4:19 pm

There are a couple of solutions that I've heard about but never tried:

(1) Pure Java AWT (PJA). Several people have said that JFreeChart works with PJA. If you search for "X11" in this forum, there are some old threads about it.

(2) JDK1.4. I recall reading that JDK1.4 was going to eliminate the dependency on X11, can anyone confirm?

Regards,

Dave Gilbert.

Robert

Re: java.lang.NoClassDefFoundError-GraphicsEnvironment.java

Post by Robert » Tue Feb 26, 2002 9:02 am

Hi,

(1) A searching does not find threads on this problem

(2) I'm working under SilverStream 3.7 and it works with jdk1.3, so I'm not
sure about installing jdk1.4

If anyone has an example for (1) or some other help....

Thanks to everyone here!

David Gilbert

Re: java.lang.NoClassDefFoundError-GraphicsEnvironment.java

Post by David Gilbert » Tue Feb 26, 2002 9:17 am

The search does work, but you need to specify all dates. Here's a link to one thread to get you started:

http://dgilbert.boson.posiweb.net/phoru ... =570&t=542

Regards,

DG.

Michiel

Re: java.lang.NoClassDefFoundError-GraphicsEnvironment.java

Post by Michiel » Thu Feb 28, 2002 12:48 pm

Jdk1.4.0 can run 'headless' by starting the jvm with -Djava.awt.headless=true. Then you 've to create a jpeg or png from the chart to file or as servlet. Tried it on w2k but not on linux without X so can't confirm if it works.

PJA should also work, can't remember but at a french site there was a pure java impl. that should run without a native graphical env.

Michiel

Locked