[英]Graphviz, GEF4 and build paths in Java
我編寫了此Java代碼,以使用Graphviz和GEF4框架顯示簡單的圖形。 重要的是,我也在Eclipse中使用Window Builder。 我創建了SWT / JFace Java項目,然后將其轉換為Plug-in項目。
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.gef4.dot.DotImport;
import org.eclipse.gef4.graph.*;
import org.eclipse.gef4.zest.fx.*;
import org.eclipse.gef4.layout.*;
import org.eclipse.gef4.layout.algorithms.*;
public class Code1 {
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell();
shell.setSize(450, 300);
shell.setText("SWT Application");
shell.setLayout(null);
Graph.Builder graph2 = new Graph.Builder().attr(ZestProperties.GRAPH_LAYOUT, new SpringLayoutAlgorithm());
new DotImport("digraph{1->2}").into(graph2);
new DotImport("node[label=zested]; 2->3; 2->4").into(graph2);
new DotImport("edge[style=dashed]; 3->5; 4->6").into(graph2);
//SpringLayoutAlgorithm SLA= new SpringLayoutAlgorithm();
graph2.build();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}
我有錯誤:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/emf/ecore/resource/ResourceSet
at org.eclipse.gef4.dot.DotImport.load(DotImport.java:81)
at org.eclipse.gef4.dot.DotImport.loadFrom(DotImport.java:63)
at org.eclipse.gef4.dot.DotImport.init(DotImport.java:55)
at org.eclipse.gef4.dot.DotImport.<init>(DotImport.java:46)
at program2.Code2.main(Code2.java:24)
Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.ecore.resource.ResourceSet
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)
... 5 more
我發現我需要在構建路徑中添加構建路徑(帶有所需庫的jar文件)。 所以我加了。 我還添加了所有依賴項。 但這仍然行不通。 你有什么主意,我想念什么? 謝謝您的任何想法!
您應該找到org.eclipse.emf.ecore.resource.ResourceSet lib並將文件jar添加到elipse。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.