如果有多个边缘,我正在两个节点上显示两条边。 我正在关注这个example。但我面临一个例外:
线程“main”中的异常java.lang.NoClassDefFoundError: scala / collection / convert / WrapAsScala at java.lang.Class.forName0(Native Method)at java.lang.Class.forName(Class.java:264)at org.graphstream.ui.view.Viewer.newGraphRenderer(Viewer.java:349)at at org.graphstream.graph.implementations.AbstractGraph.display(AbstractGraph.java:753) 在 org.graphstream.graph.implementations.AbstractGraph.display(AbstractGraph.java:747) 在com.h2Database.app.ahd.main(ahd.java:18)引起: java.lang.ClassNotFoundException:scala.collection.convert.WrapAsScala 在java.net.URLClassLoader.findClass(URLClassLoader.java:381)at java.lang.ClassLoader.loadClass(ClassLoader.java:424)at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:331)at at java.lang.ClassLoader.loadClass(ClassLoader.java:357)... 6更多
我的代码是:
import org.graphstream.graph.*;
import org.graphstream.graph.implementations.*;
import org.graphstream.ui.view.Viewer;
public class ahd {
public static void main(String args[]) {
Graph graph = new MultiGraph("Test");
System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
graph.addNode("A");
graph.addNode("B");
graph.addEdge("1", "A", "B", true);
graph.addEdge("2", "A", "B", true);
Viewer viewer = graph.display();
}
}
任何想法,为什么我要面对这个?似乎在给定的示例中,此问题已得到解决。
答案 0 :(得分:1)
GraphStream v1.3 is comprised of三个jar
个文件:
$ ls -1 lib/*1.3.jar lib/gs-algo-1.3.jar lib/gs-core-1.3.jar lib/gs-ui-1.3.jar
J2DGraphRenderer
及其内部类可以在gs-ui-1.3.jar
中找到:
$ jar tf lib/gs-ui-1.3.jar | grep org.graphstream.ui.j2dviewer.J2DGraphRenderer org/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$render$2.class org/graphstream/ui/j2dviewer/J2DGraphRenderer.class org/graphstream/ui/j2dviewer/J2DGraphRenderer$.class org/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$render$2$$anonfun$apply$1.class org/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$removeRenderers$1.class org/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$render$1.class org/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$removeRenderers$3.class org/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$removeRenderers$2.class
在运行时验证gs-ui-1.3.jar
是否在类路径中:
$ javac -cp .:lib/* ahd.java $ java -cp .:lib/* ahd
答案 1 :(得分:0)
我也遇到了这个问题。为我修复的是从 1.3 升级到 2.0。请注意,ui 包已重命名为 gs-ui-swing
(或 -javafx
或 -android
)。