Question

I've seen this question brought up a couple of times on this website, but never really seen a clear answer, so excuse me from repeating it. While programming with JOGL and Java3D I've encountered some errors. I was trying to create a project that I might eventually put on the Android App Store. I began the project just using Java3D and JOGL and putting them in the system library on my mac, where they worked fine. Then to try to make the project portable I moved the J3D and JOGL files inside the project so they could be compiled into a jar file that would be runnable without needing to install j3d and JOGL. But then every time I ran the project it threw this error:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/GL
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:190)
    at javax.media.j3d.Pipeline$PipelineCreator.run(Pipeline.java:73)
    at javax.media.j3d.Pipeline$PipelineCreator.run(Pipeline.java:61)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.media.j3d.Pipeline.createPipeline(Pipeline.java:90)
    at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:832)
    at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:274)
    at javax.media.j3d.GroupRetained.<init>(GroupRetained.java:155)
    at javax.media.j3d.TransformGroupRetained.<init>(TransformGroupRetained.java:116)
    at javax.media.j3d.TransformGroup.createRetained(TransformGroup.java:114)
    at javax.media.j3d.SceneGraphObject.<init>(SceneGraphObject.java:114)
    at javax.media.j3d.Node.<init>(Node.java:172)
    at javax.media.j3d.Group.<init>(Group.java:549)
    at javax.media.j3d.TransformGroup.<init>(TransformGroup.java:87)
    at src.Project.<clinit>(Project.java:47)
    at src.ProjectPanel.<clinit>(ProjectPanel.java:8)
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.GL
    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:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 17 more

I'm using Eclipse as an IDE, and have the jogl-all.jar and gluegen-rt.jar files in the classpath of the project, as well as all of the require j3d jars, but it cannot find the GL.class file for some reason.

Thanks in advance for help.

Was it helpful?

Solution

When you export your application as a Runnable JAR use the + Library handling: Copy required libraries into a sub-folder next to the generated JAR or + Library handling: Package required libraries into generated JAR

More information is available in the jogamp jogl wiki: http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE http://jogamp.org/wiki/index.php/JogAmp_JAR_File_Handling

Also you will need to use the java -jar yourapp.jar command line option to run your application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top