Exiting gracefully from simpleInitApp()


I would like to stop cleanly if something goes wrong during simpleInitApp().

I have tried stop() → I get ‘java.exe Application Error (…) The memory could not be read’

I have tried stop(true) → loops for ever until I kill the task…

Any idea ?

[java]public void simpleInitApp() {

try {


} catch (FileNotFoundException ex) {

Logger.getLogger(TestNeoTexture.class.getName()).log(Level.SEVERE, null, ex);

stop(); // causes java.exe error

// stop(true); // loops forever…


stop() works for me.

Are you running in a canvas by any chance?

I am not using canvas, but I could reproduce the problem with a very simple code.

it seems that simpleUpdate() is called at least once when I use stop(); the following code can reproduce the problem if you uncomment started=true :

[java]package mytests;

import com.jme3.app.SimpleApplication;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.Node;

import com.jme3.system.AppSettings;


  • test


    public class TestSimpleAppStop extends SimpleApplication {

    Node neotex_node;

    boolean started = false;

    public static void main(String[] args) {

    TestSimpleAppStop app = new TestSimpleAppStop();




    public void start() {

    settings = new AppSettings(true);

    settings.setResolution(800, 600);


    //this.setShowSettings(false); causes a failure… grrr




    public void simpleInitApp() {

    // started = true; -> uncomment to reproduce the problem




    public void simpleUpdate(float tpf) {

    if (started) {

    neotex_node.rotate(0, tpf, 0);




    public void simpleRender(RenderManager rm) {

    //TODO: add render code




I get

[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]


at testcases.TestSimpleAppStop.simpleUpdate(TestSimpleAppStop.java:37)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:248)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:144)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:173)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:218)

at java.lang.Thread.run(Thread.java:619)[/java]

But that’s because neotex_node is set to null (you haven’t set it to anything in the test)

His assumption is that since he’s called stop() that simpleUpdate() won’t be run. Which is logical even if untrue for whatever reason.

Yeah, the app exits at the end of the loop, which implies that it runs through it at least once.

Yes, stop doesn’t immediately shut down the application. The whole loop must run at least once after the stop request is made …