我必须在 Ubuntu 12.04 下运行著名的基于 java 的 Cooja 模拟器,并使用我制作的一些类进行扩展。在我的 java 文件中,我记得 jfreechart 包:
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.chart.axis.ValueAxis;
我使用以下命令运行模拟器:
$ ant run_bigmem
然后弹出一些异常:
compile:
[javac] Compiling 44 source files to /home/user/contiki_copy/tools/cooja/build
[javac] /home/user/contiki_copy/tools/cooja/java/se/sics/cooja/plugins/sixlowpan_metrics/Chart.java:7: error: package org.jfree.chart does not exist
[javac] import org.jfree.chart.ChartFactory;
[javac] ^
[javac] /home/user/contiki_copy/tools/cooja/java/se/sics/cooja/plugins/sixlowpan_metrics/Chart.java:8: error: package org.jfree.chart does not exist
[javac] import org.jfree.chart.ChartPanel;
[javac] ^
[javac] /home/user/contiki_copy/tools/cooja/java/se/sics/cooja/plugins/sixlowpan_metrics/Chart.java:9: error: package org.jfree.chart does not exist
[javac] import org.jfree.chart.JFreeChart;
.
.
.
and so on..
然后我修改了文件:/home/user/.bashrc并添加了以下几行:
export CLASSPATH=.:/home/user/contiki_copy/tools/cooja/lib/jfreechart-1.0.11.jar:/home/user/contiki_copy/tools/cooja/lib/jcommon-1.0.14.jar
然后,在提示符下,我输入:
$ echo $CLASSPATH以查看环境变量是否已正确输入,实际上我得到了:
user@ubuntu:~/contiki_copy/tools/cooja$ echo $CLASSPATH
.:/home/user/contiki_copy/tools/cooja/lib/jfreechart-1.0.11.jar:/home/user/contiki_copy/tools/cooja/lib/jcommon-1.0.14.jar
尽管所有这些努力都没有改变,我仍然得到错误..不知道该怎么做,真的,有什么想法吗?
我猜build.xml文件的关键部分如下:
<target name="run_bigmem" depends="init, compile, jar, copy configs">
<java fork="yes" dir="${build}" classname="se.sics.cooja.GUI" maxmemory="1536m">
<arg line="${args}"/>
<env key="LD_LIBRARY_PATH" value="."/>
<classpath>
<pathelement path="${build}"/>
<pathelement location="lib/jdom.jar"/>
<pathelement location="lib/log4j.jar"/>
<pathelement location="lib/jsyntaxpane.jar"/>
<pathelement location="lib/jfreechart-1.0.11.jar"/>
<pathelement location="lib/jcommon-1.0.14.jar"/>
</classpath>
</java>
我有目录中的所有 jar:/home/user/contiki_copy/tools/cooja/lib并且我正在运行目录中的所有内容:/home/user/contiki_copy/tools/cooja。