Java - JOGL部署:NoClassDefFoundError

时间:2015-10-09 11:20:30

标签: java intellij-idea jogl

Dev env:ItelliJ 14 - >编译并运行良好。

从命令行执行我自定义创建的.jar时会出现

C:\Java\Projects\OpenGLES\out\artifacts\Test1>java -jar Test1.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/jogamp/opengl/G
ventListener
        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$100(Unknown Source)
        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)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLEventListener
        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)
        ... 13 more

我试图创建.jar工件,我可以双击启动。 我认为这个问题意味着这个类找不到一些资源。 JOGL / JogAmp官方网站给出了使用JOGL部署.jars的说明,但我认为我错过了一些东西。

Test1.jar具有以下结构:

Test1.jar/
--com/
----company/
------Main.class
--jar/
----gluegen-rt.jar
----gluegen-rt-natives-windows-amd64.jar
----gluegen-rt-natives-windows-i586.jar
----jogl-all.jar
----jogl-all-natives-windows-amd64.jar
----jogl-all-natives-windows-i586.jar
--lib/
----windows-amd64/
-------gluegen-rt.dll
-------joal.dll
-------jocl.dll
-------jogl_cg.dll
-------jogl_deskop.dll
-------jogl_mobile.dll
-------nativewindow_awt.dll
-------nativewindow_win32.dll
-------newt.dll
-------soft_oal.dll
--META-INF/
----MANIFEST.MF
--com
--jar
--lib
--META-INF

manifest.mf包含 -

Manifest-Version: 1.0
Main-Class: com.company.Main

1 个答案:

答案 0 :(得分:0)

通过堆栈跟踪,似乎JVM找不到类com.jogamp.opengl.GLEventListener,这意味着它无法解析包含的jar文件的路径。 jar文件的路径不正确。点击链接查看如何正确包装罐子。

https://docs.oracle.com/javase/tutorial/deployment/jar/