What is this: Exception in thread “AWT-EventQueue-0” java.lang.ExceptionInInitializerError?

偶尔善良 提交于 2019-12-11 07:45:28

问题


I copied a java program (called SwingAccumulator.java) which enables the user to enter integers one by one in a GUI and prints the current sum. I then copied a class written by someone else (called createGraph()) to plot a line graph. I'm trying to combine the 2, calling the program ODESolver.java. The second part (createGraph()) uses JFreeChart. I've just tried to call the createGraph() method from the SwingAccumulator part and I get the following error:

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError

Can anyone help me to understand what is causing these errors and how to fix them please?

Full details of my error are as follows:

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
    at odesolver.ODESolver.createGraph(ODESolver.java:66)
    at odesolver.ODESolver.<init>(ODESolver.java:60)
    at odesolver.ODESolver$2.run(ODESolver.java:101)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.RuntimeException: Uncompilable source code - package org.jfree.util does not exist
    at org.jfree.data.general.Series.<clinit>(Series.java:69)
    ... 17 more  

I suppose the classpath has not been set properly. I've just set it to the folder containing the jfreechart-1.0.16 folder. I was wondering if the JCommon classpath hasn't been set, but I thought JCommon was included in the jfreechart-1.0.16 folder.


回答1:


As @Foo Bar User comments, both jfreechart and jcommon must be in the classpath:

java -cp lib/jfreechart-1.0.16.jar:lib/jcommon-1.0.20.jar 
    org.jfree.chart.demo.TimeSeriesChartDemo1


来源:https://stackoverflow.com/questions/19069860/what-is-this-exception-in-thread-awt-eventqueue-0-java-lang-exceptionininitia

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!