Recently in the use of Jfreechart to generate the chart, found that the project is running well locally, a deployment to the server (Linux system) does not, reported the error: Java.lang.NoClassDefFoundError:Could not Initialize class Org.jfree.chart.JFreeChart, later after the search to solve, see as follows:
1. First, this is related to the Linux system on the server, because the Linux system itself is no graphical interface, so in jfreechart chart = Chartfactory.createbarchart3d ("Outgoing result", "", "value", DataSet, Plotorientation.vertical,false, True, false); The Times made a mistake.
The 2.Tomcat changes are as follows:
After you open the%tomcat_home%/bin/catalina.sh file in-djava.io.tmpdir= "$CATALINA _tmpdir", the script that launches Tomcat is added:-djava.awt.headless= True \
"$_runjava" $JAVA _opts $CATALINA _opts
-djava.endorsed.dirs= "$JAVA _endorsed_dirs"
-classpath "$CLASSPATH"
-dcatalina.base= "$CATALINA _base"
-dcatalina.home= "$CATALINA _home"
-djava.io.tmpdir= "$CATALINA _tmpdir"
-djava.awt.headless=true
Once saved, the graphics can be processed by restarting.
The 3.headless mode itself is a system pattern, which is a system configuration when a display, keyboard, or mouse is missing. It sounds incredible, but in fact you can do different things in this mode, even with graphical data. Where can I use this mode? Think of your app to generate a picture, for example, to generate a certified image each time a user logs in. When creating a picture, you need to apply neither the monitor nor the keyboard. Let's assume that your application now has a master architecture or a proprietary server, but this service does not have a monitor, keyboard or mouse. The ideal decision is to use the vast amount of visual computing power of the environment rather than the non-visual nature. Images generated in headless mode can be passed to the headful system for deeper rendering.
Java.lang.NoClassDefFoundError:Could not initialize class Org.jfree.chart.JFreeChart