Question

I'm trying to turn my JoGL project into a jar file. What am I doing wrong?

Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/GL
EventListener
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.GLEventListener
        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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 12 more
Could not find the main class: chartest.  Program will exit.

Contents of the JAR file:

META-INF\MANIFEST.MF
gluegen-rt.jar
jogl.jar
chartest$1.class
chartest.class
gluegen-rt.dll
jogl.dll
jogl_awt.dll
jogl_cg.dll
test.png
Was it helpful?

Solution

You can check your classpath. It should include atleast

  • The jar file with classes you have written
  • Supporting jars with classes like javax.media.opengl (jogl.jar?)

Try placing all these jars in your classpath and run it.

OTHER TIPS

is Jogle jar file in your classpath ?

I see you have included the jars themselves in your jar... this unfortunately wil not work out of the box.

Either get the jars out then place in your classpath (that can be part of your manifest also) or write your own classloader...

http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html

This is why it worked for William and not for you... he got the jogl from somewhere else and did not use the one within your jar.

Switch to Netbeans to build your jar file. I find using other libraries inside of my projects including dll files its best to use something like Netbeans or just package it with maven.

mvn clean package

You need to be well versed in xml though if you want to use maven to package all of your jar files.

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