Errors reloading or restarting an applet


I’m writing a JME app in an applet using eclipse, and after much nonsense with signing jars and suchlike I have it working. However the applet only works the first time it’s loaded in a browser. Investigating a bit I found that there were errors when it tried to restart the applet, which can be reproduced on the appletviewer.

I’ve reproduced the problem with the applets in jmetest.awt.applet so I don’t think there should be a need to post any of my code. When I run the applet it works fine, and then when I hit restart I get a NullPointerException:


at org.lwjgl.opengl.GL11.glDeleteTextures(

at com.jme.scene.state.lwjgl.LWJGLTextureState.deleteAll(

at com.jme.scene.Text.resetFontTexture(

at com.jmex.awt.applet.SimpleJMEApplet.init(



I found a couple of topics here and here which mention this problem, but neither of the suggested fixes work for me.

Making the first suggested change to SimpleJMEApplet, if I put the Text.resetFontTexture() call inside the Callable created for doing setFrustumPerspective, I get a different error:

Exception in thread “AWT-EventQueue-1” java.lang.NullPointerException

at com.jme.scene.state.lwjgl.LWJGLZBufferState.enableDepthTest(

at com.jme.scene.state.lwjgl.LWJGLZBufferState.apply(

at com.jme.renderer.lwjgl.LWJGLRenderer.clearBuffers(

at com.jmex.awt.SimpleCanvasImpl.doRender(

at com.jmex.awt.lwjgl.LWJGLCanvas.paintGL(

at org.lwjgl.opengl.AWTGLCanvas.paint(

at sun.awt.RepaintArea.paintComponent(

at sun.awt.RepaintArea.paint(


at java.awt.Component.dispatchEventImpl(

at java.awt.Component.dispatchEvent(

at java.awt.EventQueue.dispatchEvent(

at java.awt.EventDispatchThread.pumpOneEventForFilters(

at java.awt.EventDispatchThread.pumpEventsForFilter(

at java.awt.EventDispatchThread.pumpEventsForHierarchy(

at java.awt.EventDispatchThread.pumpEvents(

at java.awt.EventDispatchThread.pumpEvents(


I do get some errors about not being able to install the lwjgl libs when running in the appletviewer (not in the browser), but since the applet runs anyway I’m guessing that it finds the libs in my classpath even though it can’t install them itself.

I also tried calling DisplaySystem.resetSystemProvider(); right before the createCanvas() call as suggested in the second topic, but that made no difference.

Can anyone suggest what I might try next to track down the problem? or something stupid I might have done to break it like this?

it seems to be a threading problem here. I added a start init / end init sysout and end init is never reached.

– applet is running –

– restart applet –

start init           


Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException

at com.jme.scene.state.lwjgl.LWJGLBlendState.applyBlendEquations(

When a applet is restarted, init() is called, then from another thread doRender() gets called while we're still in init() and while we're recreating stuff.

So i think either init and doRender needs to be synchronized,

or maybe it enough to add a boolean isCreated and just reset the game logic once the applet is created?

    public void init() {
       if (isCreated) {
                // just reset positions and stuff to reset your game here
       isCreated = true;

Hey baldurk,

I've had the same problem.  Unfortunately I don't perfect explanation or a quick fix for you.  I had a number of problems getting jME working in applets and found myself going directly to LWJGL which doesn't seem to have the same problems.  Then, I built up from there slowly and reintroducing jME.  The result is a custom Loader and Canvas class.  The loader is based on the LWJGL examples and the Canvas is based on the jME's LWJGLCanvas.  You can do the same thing if you use a custom JMECanvasImplementor if you wanted to.

Anyway, Code Dump is right.  It is a thread issue and its been as long as SimpleJMEApplet, but only causes the null pointer exception when you reload the applet and that is because your applet is using the same VM and all your static variables are still around from the first time you loaded.  Anyway, you can dig around deeper if you want to, but if you want to fix the problem get the "resetFontTexture" call into the paintGL().  There is a onetime setup that the LWJGLCanvas uses you can do something like that if you want.

Anyway, I'm sorry for the late response.  I rarely check these forum.  If you have any more applet specific problems you can always post here and ping me at

Good luck