OPENGL error when compiling with Eclipse

Hi guys, I am attempting to compile a sketch with Eclipse, following the tutorial by Daniel Shiffman at http://www.learningprocessing.com/tutorials/processing-in-eclipse/

It seems to work, but when I need to render with OPENGL it gives me some errors:

java.lang.NoClassDefFoundError: javax/media/opengl/awt/GLCanvas
    at processing.opengl.PGraphicsOpenGL.createPGL(PGraphicsOpenGL.java:1744)
    at processing.opengl.PGraphicsOpenGL.<init>(PGraphicsOpenGL.java:518)
    at processing.opengl.PGraphics3D.<init>(PGraphics3D.java:37)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at processing.core.PApplet.makeGraphics(PApplet.java:1919)
    at processing.core.PApplet.size(PApplet.java:1771)
    at processing.core.PApplet.size(PApplet.java:1742)
    at exoskeleton.MyProcessingSketch.setup(MyProcessingSketch.java:66)
    at processing.core.PApplet.handleDraw(PApplet.java:2361)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
    at processing.core.PApplet.run(PApplet.java:2256)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.awt.GLCanvas
    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)
    ... 15 more
Exception in thread "Animation Thread" java.lang.RuntimeException: javax/media/opengl/awt/GLCanvas
    at processing.core.PApplet.makeGraphics(PApplet.java:1944)
    at processing.core.PApplet.size(PApplet.java:1771)
    at processing.core.PApplet.size(PApplet.java:1742)
    at exoskeleton.MyProcessingSketch.setup(MyProcessingSketch.java:66)
    at processing.core.PApplet.handleDraw(PApplet.java:2361)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
    at processing.core.PApplet.run(PApplet.java:2256)
    at java.lang.Thread.run(Unknown Source)

Any idea about it? Hope that it is correct section. Thanks

Answers

  • Answer ✓

    As well as core.jar you need to add all the opengl jars to the buildpath

  • This discussion might help

  • OK now it works, thanks a lor for the reply

  • Hello, I too am trying to do P3D via eclipse but I get a different error. I did add all 5 libs (jolg, glugen. core) to my buold path. But I still get an error in java when trying to execute the command size(640, 360, P3D);

    I note that I do not get this error when running the identical command in processing.app (I am running on osx).

    Exception in thread "Animation Thread" processing.core.PApplet$RendererChangeException at processing.core.PApplet.size(PApplet.java:1785) at processing.core.PApplet.size(PApplet.java:1742) at helloWorld.helloWorld.draw(helloWorld.java:12) at processing.core.PApplet.handleDraw(PApplet.java:2386) at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240) at processing.core.PApplet.run(PApplet.java:2256) at java.lang.Thread.run(Thread.java:745)

    and here is the code:

    package helloWorld;

    import processing.core.*;

    public class helloWorld extends PApplet {

    public void setup() {

    }

    public void draw() { size(640, 360, P3D);

    } }

  • Hi. GoToLoop, the size command works just fine when run as java in processing.app so evidently there's nothing wrong with the format.

    I just installed proclipsing to test if I just was badly installing the libraries. I created a new processing project, and I told it to import all of the libraries listed even ones whose name seemed unlikely to matter.

    it still gives the same error. I'm using Yosemite OSX. I'm wondering if perhaps this has something to do with which java it is using they computer has multiple installs of java. It has the built in on, java 1.8 from oracle, the older 1.6 that eclipse asked me to install, and the one netBeans might have installed (probably 1.8).

    again here's a paste of the new code. You can see I'm trying to use the 3D primitives example from the processing web page. this works in processing.app on the same computer.

    package testprocessing;
    
    import processing.core.PApplet;
    
    
    public class TestProcessing extends PApplet {
    
        public void setup() {
        }
    
        public void draw() {
              size(640, 360, P3D); 
              background(0);
              lights();
    
              noStroke();
              pushMatrix();
              translate(130, height/2, 0);
              rotateY(1.25f);
              rotateX(-0.4f);
              box(100);
              popMatrix();
    
              noFill();
              stroke(255);
              pushMatrix();
              translate(500.0f, height*0.35f, -200.0f);
              sphere(280);
              popMatrix();
        }
    }
    
  • edited July 2015

    Hello again. I got this to work when I moved the size() command into the setup(). that's logical but It's not clear why the processing.app runs it just fine when all the commands in my draw loop are in the code. Anyhow that works!

    package testprocessing;
    
    import processing.core.PApplet;
    
    
    public class TestProcessing extends PApplet {
    
    public void setup() {
          size(640, 360, P3D); 
          background(0);
          lights();
    }
    
    public void draw() {
    
        background(127,0,127);
    
          fill(200);
          noStroke();
          pushMatrix();
          translate(130.0f, height/2.0f, 0.0f);
          rotateY(1.25f);
          rotateX(-0.4f);
          box(100.0f);
          popMatrix();
    
          noFill();
          stroke(255);
          pushMatrix();
          translate(500.0f, height*0.35f, -200.0f);
          sphere(280.0f);
          popMatrix();
    }
    }
    
Sign In or Register to comment.