1
votes

I am working to show two edges on two nodes if there are more than one edge. I am following this example. But I am facing an exception:

Exception in thread "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 org.graphstream.graph.implementations.AbstractGraph.display(AbstractGraph.java:753) at org.graphstream.graph.implementations.AbstractGraph.display(AbstractGraph.java:747) at com.h2Database.app.ahd.main(ahd.java:18) Caused by: java.lang.ClassNotFoundException: scala.collection.convert.WrapAsScala at 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 java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 6 more

my code is :

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();
    }
}

Any idea, why I am facing this ? It seems that in given example this issue is resolved.

2
Please specify which version of gs-core and gs-ui you are using.Yoann
@Yoann 1.3 , latest versionNoob Player

2 Answers

1
votes

GraphStream v1.3 is comprised of three jar files:

$ 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 and its inner classes may be found in 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

Verify that gs-ui-1.3.jar is in the classpath at runtime:

$ javac -cp .:lib/* ahd.java 
$ java -cp .:lib/* ahd

image

Note that classpath syntax is OS-dependent.

0
votes

I also ran into this problem. What fixed it for me is to upgrade from 1.3 to 2.0. Note that the ui package has been renamed to gs-ui-swing (or -javafx or -android).