Java Eclipse class not found exception (javax/media/opengl/GLCanvas)

1.7k Views Asked by At

I am trying to implement gephi 3d atlas and getting java.lang.NoClassDefFoundError :

Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/GLCanvas
at org.gephi.visualization.config.VizCommander.createCanvas(VizCommander.java:54)
at org.gephi.visualization.VizController.initInstances(VizController.java:138)
at org.gephi.visualization.VizController.getInstance(VizController.java:94)
at net.clementlevallois.ForceAtlas3D.ForceAtlas2.initAlgo(ForceAtlas2.java:156)
at org.gephi.toolkit.demos.MYSQLImportExport.script(MYSQLImportExport.java:113)
at org.gephi.toolkit.demos.PreviewJFrame.main(PreviewJFrame.java:100)

here is the ForceAtlas2 class implementation (error on last line):

    package net.clementlevallois.ForceAtlas3D;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.concurrent.ExecutionException;
    import java.util.concurrent.ExecutorService;
    import java.util.concurrent.Executors;
    import java.util.concurrent.Future;

    import net.clementlevallois.ForceAtlas3D.ForceFactory.AttractionForce;
    import net.clementlevallois.ForceAtlas3D.ForceFactory.RepulsionForce;

    import org.gephi.data.attributes.type.TimeInterval;
    import org.gephi.dynamic.DynamicUtilities;
    import org.gephi.dynamic.api.DynamicController;
    import org.gephi.dynamic.api.DynamicModel;
    import org.gephi.graph.api.Edge;
    import org.gephi.graph.api.GraphModel;
    import org.gephi.graph.api.HierarchicalGraph;
    import org.gephi.graph.api.Node;
    import org.gephi.graph.api.NodeData;
    import org.gephi.graph.spi.LayoutData;
    import org.gephi.layout.spi.Layout;
    import org.gephi.layout.spi.LayoutBuilder;
    import org.gephi.layout.spi.LayoutProperty;
    import org.gephi.project.api.Workspace;
    import org.gephi.visualization.*;
    import org.gephi.visualization.api.initializer.Modeler;
    import org.gephi.visualization.api.initializer.NodeModeler;
    import org.gephi.visualization.api.objects.ModelClass;
    import org.gephi.visualization.api.objects.ModelClassLibrary;
    import org.openide.util.Exceptions;
    import org.openide.util.Lookup;
    import org.openide.util.NbBundle;
    import javax.media.opengl.awt.GLCanvas;
    import javax.media.opengl.*;
    import javax.media.opengl.GL;
    import javax.media.opengl.GL2;
    import javax.media.opengl.GLAutoDrawable;
    import javax.media.opengl.GLCapabilities;
    import javax.media.opengl.GLProfile;
    import javax.media.opengl.GLEventListener;
    import javax.media.opengl.awt.GLCanvas;
    import com.jogamp.opengl.*;
    import javax.media.opengl.awt.GLCanvas;


    /**
     * ForceAtlas 2 Layout, manages each step of the computations.
     *
     * @author Mathieu Jacomy
     */
    public class ForceAtlas2 implements Layout {

        private GraphModel graphModel;
        private HierarchicalGraph graph;
        private final ForceAtlas2Builder layoutBuilder;
        private DynamicModel dynamicModel;
        private double edgeWeightInfluence;
        private double jitterTolerance;
        private double scalingRatio;
        private double gravity;
        private double speed;
        private boolean outboundAttractionDistribution;
        private boolean adjustSizes;
        private boolean threeD;
        private boolean barnesHutOptimize;
        private double barnesHutTheta;
        private boolean linLogMode;
        private boolean strongGravityMode;
        private int threadCount;
        private int currentThreadCount;
        private Region rootRegion;
        double outboundAttCompensation = 1;
        //Dynamic Weight
        private TimeInterval timeInterval;
        private ExecutorService pool;
        private ModelClass nodeClass;
        private NodeModeler originalNodeModeler;

        public ForceAtlas2(ForceAtlas2Builder layoutBuilder) {
            this.layoutBuilder = layoutBuilder;
            this.threadCount = Math.min(4, Math.max(1, Runtime.getRuntime().availableProcessors() - 1));
        }

        @Override
        public void initAlgo() {
            speed = 1.;

            graph = graphModel.getHierarchicalGraphVisible();
            this.timeInterval = DynamicUtilities.getVisibleInterval(dynamicModel);

            graph.readLock();
            Node[] nodes = graph.getNodes().toArray();

            // Initialise layout data
            for (Node n : nodes) {
                if (n.getNodeData().getLayoutData() == null || !(n.getNodeData().getLayoutData() instanceof ForceAtlas2LayoutData)) {
                    ForceAtlas2LayoutData nLayout = new ForceAtlas2LayoutData();
                    n.getNodeData().setLayoutData((LayoutData) nLayout);
                }
                NodeData nData = n.getNodeData();
                ForceAtlas2LayoutData nLayout = nData.getLayoutData();
                nLayout.mass = 1 + graph.getDegree(n);
                nLayout.old_dx = 0;
                nLayout.old_dy = 0;
                nLayout.old_dz = 0;
                nLayout.dx = 0;
                nLayout.dy = 0;
                nLayout.dz = 0;
            }
            ModelClass nodeClass;
            //nodeClass = org.gephi.visualization.VizController.getInstance().getModelClassLibrary().getNodeClass();
            //nodeClass = org.gephi.visualization.VizController.getInstance().getModelClassLibrary().getNodeClass();
            VizController vc = org.gephi.visualization.VizController.getInstance();

...

Project explorer + jars that I added to the buil dpath attached any help much appreciated, thanksenter image description here

1

There are 1 best solutions below

0
On

Always ensure that you have only the correct version of .jar files in classpath.

Otherwise, Classloader may find the wrong one and try to get the class file, which doesn't actually exist in it, but in the newer jar version. I can definitely tell that this is such a problem. Please try organizing the Classpath only with the required jar files.

Please find out the .jar file which has the same package without GLCanvas class.