运行Zest / Dot程序的问题

时间:2014-01-05 12:36:53

标签: java eclipse zest

我正在尝试创建一个简单的Java程序,它使用Zest框架从.dot输入图生成和显示图形。我已经将整个gef4框架下载到我的eclipse中,并且我创建了两个示例java程序来测试普通图形和点图形的可视化。普通图表工作正常,但是当我尝试运行点图时,我最终得到以下错误(这对我来说没什么意义)

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/emf/ecore/util/Switch
at java.lang.ClassLoader.defineClass1(Native Method)
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$100(Unknown Source)
at java.net.URLClassLoader$1.run(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 java.lang.ClassLoader.defineClass1(Native Method)
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$100(Unknown Source)
at java.net.URLClassLoader$1.run(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.eclipse.gef4.zest.dot.DotGraph.<init>(DotGraph.java:37)
at test2.SampleDotGraph.main(SampleDotGraph.java:19)
Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.ecore.util.Switch
at java.net.URLClassLoader$1.run(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)
... 26 more

java代码如下:

import org.eclipse.gef4.zest.dot.DotGraph;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SampleDotGraph {

public static void main(String[] args) {
    Display d = new Display();
    Shell shell = new Shell(d);
    shell.setText("GraphSnippet1");
    shell.setLayout(new FillLayout());
    shell.setSize(400, 400);

    DotGraph graph = new DotGraph("digraph{ 1->2 }", shell, SWT.NONE);
    graph.add("2->3").add("2->4");
    graph.add("node[label=zested]; edge[style=dashed]; 3->5; 4->6");

    shell.open();
    while (!shell.isDisposed()) {
        while (!d.readAndDispatch()) {
            d.sleep();
        }
    }
}

}

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

正确阅读错误堆栈

java.lang.ClassNotFoundException: org.eclipse.emf.ecore.util.Switch
at java.net.URLClassLoader$1.run(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)

应用程序无法在run()方法中找到URLClassLoader类中的类。