JOGL Now Crashing (Fixed)

Hello everyone and thanks for reading my post!

I am having trouble getting the new version of JOGL to work on my computer (I am currently running Windows XP); it was working well before, but now I receive a RuntimeException and my programs crash upon startup:

Exception in thread “main” java.lang.RuntimeException: Unable to initialize JAWT
at com.sun.nativewindow.impl.jawt.JAWT$1.run(JAWT.java:100)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.nativewindow.impl.jawt.JAWT.getJAWT(JAWT.java:95)
at com.sun.nativewindow.impl.jawt.windows.WindowsJAWTWindow.lockSurface(WindowsJAWTWindow.java:69)
at com.sun.opengl.impl.GLDrawableImpl.lockSurface(GLDrawableImpl.java:121)
at com.sun.opengl.impl.windows.wgl.WindowsWGLDrawable.setRealized(WindowsWGLDrawable.java:70)
at glux.awt.GLXCanvas.addNotify(GLXCanvas.java:192)
at java.awt.Container.addNotify(Container.java:2578)
at javax.swing.JComponent.addNotify(JComponent.java:4685)
at java.awt.Container.addNotify(Container.java:2578)
at javax.swing.JComponent.addNotify(JComponent.java:4685)
at java.awt.Container.addNotify(Container.java:2578)
at javax.swing.JComponent.addNotify(JComponent.java:4685)
at java.awt.Container.addNotify(Container.java:2578)
at javax.swing.JComponent.addNotify(JComponent.java:4685)
at javax.swing.JRootPane.addNotify(JRootPane.java:739)
at java.awt.Container.addNotify(Container.java:2578)
at java.awt.Window.addNotify(Window.java:662)
at java.awt.Frame.addNotify(Frame.java:470)
at java.awt.Window.show(Window.java:858)
at java.awt.Component.show(Component.java:1563)
at java.awt.Component.setVisible(Component.java:1515)
at java.awt.Window.setVisible(Window.java:841)
at test.GLXCanvasTest.initializeFrame(GLXCanvasTest.java:77)
at test.GLXCanvasTest.(GLXCanvasTest.java:48)
at test.GLXCanvasTest.main(GLXCanvasTest.java:210)

I used a custom implementation of a GLCanvas which I modified for the new version of the API, so I tried using the GLCanvas provided with JOGL; however, more exceptions were thrown:

[i]Exception in thread “main” java.lang.RuntimeException: Unable to initialize JAWT
at com.sun.nativewindow.impl.jawt.JAWT$1.run(JAWT.java:100)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.nativewindow.impl.jawt.JAWT.getJAWT(JAWT.java:95)
at com.sun.nativewindow.impl.jawt.windows.WindowsJAWTWindow.lockSurface(WindowsJAWTWindow.java:69)
at com.sun.opengl.impl.GLDrawableImpl.lockSurface(GLDrawableImpl.java:121)
at com.sun.opengl.impl.windows.wgl.WindowsWGLDrawable.setRealized(WindowsWGLDrawable.java:70)
at javax.media.opengl.awt.GLCanvas.addNotify(GLCanvas.java:413)
at java.awt.Container.addNotify(Container.java:2578)
at java.awt.Window.addNotify(Window.java:662)
at java.awt.Frame.addNotify(Frame.java:470)
at java.awt.Window.show(Window.java:858)
at java.awt.Component.show(Component.java:1563)
at java.awt.Component.setVisible(Component.java:1515)
at java.awt.Window.setVisible(Window.java:841)
at test.JOGLAPP.(JOGLAPP.java:31)
at test.JOGLAPP.main(JOGLAPP.java:16)
java.lang.Exception: JAWT Surface previously locked by main
at com.sun.nativewindow.impl.jawt.JAWTWindow.lockSurface(JAWTWindow.java:96)
at com.sun.nativewindow.impl.jawt.windows.WindowsJAWTWindow.lockSurface(WindowsJAWTWindow.java:60)
at com.sun.opengl.impl.GLDrawableImpl.lockSurface(GLDrawableImpl.java:121)
at com.sun.opengl.impl.windows.wgl.WindowsWGLDrawable.setRealized(WindowsWGLDrawable.java:70)
at javax.media.opengl.awt.GLCanvas.addNotify(GLCanvas.java:413)
at java.awt.Container.addNotify(Container.java:2578)
at java.awt.Window.addNotify(Window.java:662)
at java.awt.Frame.addNotify(Frame.java:470)
at java.awt.Window.show(Window.java:858)
at java.awt.Component.show(Component.java:1563)
at java.awt.Component.setVisible(Component.java:1515)
at java.awt.Window.setVisible(Window.java:841)
at test.JOGLAPP.(JOGLAPP.java:31)
at test.JOGLAPP.main(JOGLAPP.java:16)
Exception in thread “AWT-EventQueue-0” javax.media.nativewindow.NativeWindowException: JAWT Surface already locked - AWT-EventQueue-0 JAWT-Window[windowHandle 0x0, surfaceHandle 0x0, pos 4/34, size 292x262, visible true, locked true,
config class javax.media.nativewindow.awt.AWTGraphicsConfiguration[class javax.media.nativewindow.awt.AWTGraphicsScreen[class javax.media.nativewindow.awt.AWTGraphicsDevice[type AWT, awtDevice D3DGraphicsDevice[screen=0],

[/i]

It now mentions something about the AWT surface already being locked. I find this strange because everything was working well in the previous version; I suspect that I installed JOGL incorrectly (I did what I usually do and placed the files in the bin and lib/ext directories). If it helps, my programs always crash in the line where I call drawable.setRealized(true);. Why is there a problem initializing JAWT? Any help would be greatly appreciated; thank you very much!

Sounds like maybe a threading issue. From the stack trace it looks like you are messing with Swing stuff from the main thread instead of the event dispatch thread. Try wrapping your current main code with a SwingUtilities.invokeLater call.

Hello and thanks for the suggestion! After wrapping the code in main in SwingUtilities.invokeLater(…), I still received the same exception. I even copy-pasted some examples which were online and got the same problem, which makes me think that I did something wrong when I installed JOGL; however, my code compiled, so I don’t understand what could have gone wrong… ???

Edit 0: The class I used to cross-check with the exception my code was throwing can be found here: http://blog.rickyc.org/?p=39. I copy-pasted the code found there verbatim, which caused the second exception I noted in my original post. My guess at this point is that awt.dll and jawt.dll could not be found in the class which loads the native libraries; however, I’m pretty sure I installed everything correctly; I pasted the jogl files and dlls (along with awt.dll and jawt.dll) in bin and lib/ext. Did I do something wrong here?

Edit 1: I fixed the problem! Looks like copy-pasting all of the contents in the lib folder of the jogl installation package into the lib/ext and bin directories of the JDK is not a good idea. After only copying over the .dlls and the main jar files (jogl.all.jar, gluegen, and nativewindow), everything works!