0

我正在尝试使用 Jzy3D 库并在 openGl 下绘制一些图表。但是当我尝试编译代码时,我得到以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/GLCanvas
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.jzy3d.chart.Chart.initializeCanvas(Chart.java:65)
    at org.jzy3d.chart.Chart.<init>(Chart.java:56)
    at org.jzy3d.chart.Chart.<init>(Chart.java:39)
    at mychart.MyChart.<init>(MyChart.java:44)
    at mychart.MyChart.main(MyChart.java:58)
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.GLCanvas
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 17 more

我还添加了我编写的代码,以防出现问题:

package mychart;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;

import org.jzy3d.chart.Chart;
import org.jzy3d.colors.Color;
import org.jzy3d.colors.ColorMapper;
import org.jzy3d.colors.colormaps.ColorMapRainbow;
import org.jzy3d.maths.Range;
import org.jzy3d.plot3d.builder.Builder;
import org.jzy3d.plot3d.builder.Mapper;
import org.jzy3d.plot3d.builder.concrete.OrthonormalGrid;
import org.jzy3d.plot3d.primitives.Shape;
import org.jzy3d.plot3d.rendering.legends.colorbars.ColorbarLegend;

public class MyChart {

    protected Chart chart;

    public MyChart(){

        Mapper mapper = new Mapper(){

            @Override
            public double f(double x, double y) {
                // TODO Auto-generated method stub
                return 20*x*(1-Math.sin(y));
            }
        };

        Range range = new Range(-100, 100);
        int steps = 30;

        final Shape surface = (Shape) Builder.buildOrthonormal
                (new OrthonormalGrid(range, steps, range, steps), mapper);
        surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), 
                surface.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
        surface.setFaceDisplayed(true);
        surface.setWireframeDisplayed(true);
        surface.setWireframeColor(Color.BLACK);

        chart = new Chart();
        chart.getScene().getGraph().add(surface);

        ColorbarLegend cl = new ColorbarLegend(surface, chart.getView().getAxe().getLayout());
        cl.setMinimumSize(new Dimension(100, 300));

        surface.setLegend(cl);  
    }

    public Chart getChart(){
        return chart;
    }

    public static void main(String[] args){
        MyChart myChart = new MyChart();

        Frame frame = new Frame();
        frame.setSize(1000, 600);
        frame.add((Component)myChart.getChart().getCanvas());
        frame.setVisible(true);
    }
}

我正在使用 Eclipse Indigo IDE、Jogl 2.0 库(当我将它们导入 Eclipse 时,我填写了本机库路径)、Jzy3D 0.8.4 版本。我在 Windows 7 Ultimate 下工作。

4

1 回答 1

0

Jzy3D 可能需要 JOGL 1.x

于 2011-07-30T10:19:01.127 回答