Code seems to be okay according to netbeans prior to run attempt but fails to run

classic Classic list List threaded Threaded
6 messages Options
s3a
Reply | Threaded
Open this post in threaded view
|

Code seems to be okay according to netbeans prior to run attempt but fails to run

s3a
I'm planning to use JOGL 2.x and I'm getting issues with the migration. If it matters, I am using OpenJDK 7 and Netbeans 7.0.1.

The error says:
Exception in thread "main" java.lang.NoClassDefFoundError: com/jogamp/common/os/Platform
        at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:1155)
        at SimpleScene.main(SimpleScene.java:15)
Caused by: java.lang.ClassNotFoundException: com.jogamp.common.os.Platform
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
        ... 2 more
Java Result: 1

The code I copied (I changed one line - what that line used to be is left as a commented line):
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.*;
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.*;

public class SimpleScene implements GLEventListener {

    private double theta = 0;
    private double s = 0;
    private double c = 0;

    public static void main(String[] args) {
        GLProfile glp = GLProfile.get(GLProfile.GL2);
        GLCapabilities caps = new GLCapabilities(glp);
//        GLCanvas canvas = new GLCanvas(caps);
        GLCanvas canvas = new GLCanvas();

        Frame frame = new Frame("AWT Window Test");
        frame.setSize(300, 300);
        frame.add(canvas);
        frame.setVisible(true);

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        canvas.addGLEventListener(new SimpleScene());

        FPSAnimator animator = new FPSAnimator(canvas, 60);
        animator.add(canvas);
        animator.start();
    }

    @Override
    public void display(GLAutoDrawable drawable) {
        update();
        render(drawable);
    }

    @Override
    public void dispose(GLAutoDrawable drawable) {
    }

    @Override
    public void init(GLAutoDrawable drawable) {
    }

    @Override
    public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
    }

    private void update() {
        theta += 0.01;
        s = Math.sin(theta);
        c = Math.cos(theta);
    }

    private void render(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();

        gl.glClear(GL.GL_COLOR_BUFFER_BIT);

        // draw a triangle filling the window
        gl.glBegin(GL.GL_TRIANGLES);
        gl.glColor3f(1, 0, 0);
        gl.glVertex2d(-c, -c);
        gl.glColor3f(0, 1, 0);
        gl.glVertex2d(0, c);
        gl.glColor3f(0, 0, 1);
        gl.glVertex2d(s, -s);
        gl.glEnd();
    }
}

Any input would be greatly appreciated!
Thanks in advance!
Reply | Threaded
Open this post in threaded view
|

Re: Code seems to be okay according to netbeans prior to run attempt but fails to run

Wade Walker
Administrator
Have you set things up in NetBeans as described at http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE#NetBeans_IDE?

You might also take a look at http://jogamp.org/wiki/index.php/Downloading_and_installing_JOGL, which I've just revised (though it doesn't yet cover the new auto-extracting libraries that Sven recently added).
s3a
Reply | Threaded
Open this post in threaded view
|

Re: Code seems to be okay according to netbeans prior to run attempt but fails to run

s3a
Actually, I obtained JOGL 2 from the Debian repositories:

deniz@debian:~$ dpkg -L libjogl2-java
/.
/usr
/usr/share
/usr/share/java
/usr/share/java/jogl2.jar
/usr/share/doc
/usr/share/doc/libjogl2-java
/usr/share/doc/libjogl2-java/changelog.Debian.gz
/usr/share/doc/libjogl2-java/copyright
/usr/share/doc/libjogl2-java/README.Debian
deniz@debian:~$

and it's the bold JAR which I am using as the library.


I am using the following version:

deniz@debian:~$ apt-cache policy libjogl2-java
libjogl2-java:
  Installed: 2.0-rc3-7
  Candidate: 2.0-rc3-7
  Version table:
 *** 2.0-rc3-7 0
        500 http://ftp.ca.debian.org/debian/ wheezy/main amd64 Packages
        100 /var/lib/dpkg/status
deniz@debian:~$

In other words, I don't think I am doing anything wrong and I also think I am doing what the website you gave me is saying to do (unless I am missing a minor detail but I don't think that that is the case).
Reply | Threaded
Open this post in threaded view
|

Re: Code seems to be okay according to netbeans prior to run attempt but fails to run

gouessej
Administrator
Hi

The Debian package for JOGL 2.0 does not contain GlueGen and all native libraries. Please use the latest release candidate (RC5), extract jogl.all.jar, gluegen-rt.jar and the JARs containing native libraries, put them in the same directory, put jogl.all.jar and gluegen-rt.jar into your class path and it should work fine. In Netbeans, in the project tab, select the "Libraries" node -> "Add JAR/Folder" and select jogl.all.jar and gluegen-rt.jar. You don't have to set the library path.

Edit.: I'm a daily user of GNU Linux (Mageia Linux 1, Cent OS Linux 5.3), I can help
Julien Gouesse | Personal blog | Website
s3a
Reply | Threaded
Open this post in threaded view
|

Re: Code seems to be okay according to netbeans prior to run attempt but fails to run

s3a
Thank you, I solved the problem. I just needed gluegen2 in addition to jogl2.

Don't read the following if you don't care:

Actually, Debian has gluegen2 in another Debian package. I really insist on using Debian packages because of the auto-update mechanism which suits me very well. I know you guys think I should use the versions on this website (which I was until I found that gluegen2 was also in Debian) but I just don't like being responsible for upgrading my libraries (or anything else for that matter). I even compile upstream programs to deb files if they're not in the repositories so that when it does come to the Debian version I am using, it will simply upgrade itself.
Reply | Threaded
Open this post in threaded view
|

Re: Code seems to be okay according to netbeans prior to run attempt but fails to run

gouessej
Administrator
actually i had asked sven to provide packages for jogl but he convinced me that it is not the way to go, it is not the java way. if you don't benefit of cutting edge versions with latest fixes, it will not be our problem, it will be the problem of debian package managers, keep it in mind
Julien Gouesse | Personal blog | Website