I have the latest version of Java and JOGL2 installed. After experimenting, I want to compile and run the most basic JOGL2 program possible. I have:

import javax.media.opengl.awt.GLCanvas;
public class Test {
  public static void main(String[] args) {
    GLCanvas canvas = new GLCanvas();

I can compile this using:

>javac -cp /usr/lib/java/jogl2.jar Test.java

However, I cannot run the program. I have tried many methods of setting the classpath or using -Djava.library.path. Nothing works. I always get a class not found error. This is a selection of things I've tried. I remove the extended error trace for brevity...

>java Test
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/awt/GLCanvas

>java -cp /usr/lib/java/jogl2.jar Test
Error: Could not find or load main class Test

>java -cp ".:/usr/lib/java/jogl2.jar" Test
Exception in thread "main" java.lang.NoClassDefFoundError: com/jogamp/common/type/WriteCloneable

As you can see, it isn't rather obvious how to run a JOGL program, which leads me to believe that it isn't a good idea to develop with JOGL. If the developer cannot run the program, nobody else will be able to either. Is there a simple trick to make JOGL programs function?

Related posts

Recent Viewed