在IntelliJ 2016.2.5 / MAC OS Sierra 10.12.1中运行JOGL2时出错

时间:2016-11-07 19:47:37

标签: java macos intellij-idea 3d jogl

我正在尝试在IntelliJ 2016.2.5 / MAC OS Sierra 10.12.1中运行使用JOGL2的java程序。

我有一个包含以下子文件夹的文件夹JOGL2:

jar
lib

我添加了JOGL2 \ jar文件夹,其中所有gluegenjogl变体(取决于系统)都可以在IntelliJ中找到库,IDE不会强调任何错误在跑步之前。

jar folder added as a library 在这里,您可以看到一些文件,这些文件作为jar文件夹的一部分添加。

我确信代码工作正常,因为我可以通过终端运行它,但不能在IntelliJ中运行。当我尝试运行程序时出现以下错误。

编辑:事实证明它与package语句有关。如果我删除包名并通过终端运行,它就可以正常工作。

Error loading texture image.jpg
Error loading texture image2.jpg
Exception in thread "main-FPSAWTAnimator#00-Timer0" com.jogamp.opengl.util.AnimatorBase$UncaughtAnimatorException: java.lang.RuntimeException: com.jogamp.opengl.GLException: Caught NullPointerException: null on thread AWT-EventQueue-0
    at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:92)
    at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
    at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.RuntimeException: com.jogamp.opengl.GLException: Caught NullPointerException: null on thread AWT-EventQueue-0
    at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
    at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)
    at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:201)
    at com.jogamp.opengl.Threading.invokeOnOpenGLThread(Threading.java:202)
    at com.jogamp.opengl.Threading.invoke(Threading.java:221)
    at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:505)
    at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
    ... 4 more
Caused by: com.jogamp.opengl.GLException: Caught NullPointerException: null on thread AWT-EventQueue-0
    at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1438)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Caused by: java.lang.NullPointerException
    at mypackage.Show.computeImmediateMode(Show.java:96)
    at mypackage.Show.computeDisplayList(Show.java:133)
    at mypackage.GraphicScene.createRenderObjects(GraphicScene.java:70)
    at mypackage.GraphicScene.<init>(GraphicScene.java:57)
    at mypackage.Graphic.init(Graphic.java:217)
    at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:644)
    at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:667)
    at com.jogamp.opengl.awt.GLCanvas$10.run(GLCanvas.java:1407)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1291)
    ... 16 more
Exception in thread "AWT-EventQueue-0" com.jogamp.opengl.GLException: Caught NullPointerException: null on thread AWT-EventQueue-0
    at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1438)
    at com.jogamp.opengl.Threading.invoke(Threading.java:223)
    at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:505)
    at com.jogamp.opengl.awt.GLCanvas.paint(GLCanvas.java:559)
    at sun.awt.RepaintArea.paintComponent(RepaintArea.java:264)
    at sun.lwawt.LWRepaintArea.paintComponent(LWRepaintArea.java:59)
    at sun.awt.RepaintArea.paint(RepaintArea.java:240)
    at sun.lwawt.LWComponentPeer.handleJavaPaintEvent(LWComponentPeer.java:1314)
    at sun.lwawt.LWComponentPeer.handleEvent(LWComponentPeer.java:1198)
    at java.awt.Component.dispatchEventImpl(Component.java:4965)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NullPointerException
    at mypackage.Tex3.reshape(Tex3.java:236)
    at jogamp.opengl.GLDrawableHelper.reshape(GLDrawableHelper.java:751)
    at com.jogamp.opengl.awt.GLCanvas$11.run(GLCanvas.java:1420)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
    ... 30 more
2016-11-08 02:30:35.962 java[15337:804493] IMKInputSession presentFunctionRowItemTextInputViewWithEndpoint:completionHandler: : *NO* NSRemoteViewController to client, NSError=Error Domain=NSCocoaErrorDomain Code=4099 "The connection from pid 0 was invalidated from this process." UserInfo={NSDebugDescription=The connection from pid 0 was invalidated from this process.}, com.apple.inputmethod.EmojiFunctionRowItem

知道如何解决这个问题吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

好的,我已成功解决了这个问题。

我从java文件夹中获取了图片文件并将它们放入 src 强>

此外,我研究了加载资源的最佳方法。因此,我改变了代码:

File f = new File(filename);
BufferedImage img = ImageIO.read(f);

为:

BufferedImage img = ImageIO.read(getClass().getResource(filename));

,文件名直接作为String&#34; /img/image1.jpg"

传递