Use Headless application AssetManager outside JME thread

I want to build a desktop program (JavaFX) that has to load and save j3o models. Because of that, I can’t run the code in the jme thread. I used the following code to instantiate the headless application:

public class JMEHeadless extends SimpleApplication {

    private static JMEHeadless app = new JMEHeadless();

    public void simpleInitApp() {

    public static SimpleApplication getApp() {
        if (app == null) {
        return app;


When I try to get the AssetManager sometimes it gives null even if the application took its time.

1 Like

You have to wait for the application to start.

But really, you don’t need to have a whole application just to load assets.

Edit: example of loading assets without having a JME application: JmeConvert/ at master · Simsilica/JmeConvert · GitHub

1 Like

Thanks very much for the answer @pspeed.
Also, I want to ask if there is a recommended way to load the j3o files. I used the FileLocator for loading j3o by setting the root path to the canonical path of the j3o parent file. I did this for each time I want to load a j3o file. This way also will cause some problems in loading the j3o file because it doesn’t put a correct root path so the textures keys or other assets can be loaded for a specific model. Could I know the correct root path from the j3o file? Is there a better way to load the files where I don’t have to put the root path each time especially when I don’t want to show that model but read it.

assetManager.registerLocator(J3O.getParentFile().getCanonicalPath(), FileLocator.class);

You can import j3o with the binary importer directly… but if it refers to other assets then I don’t think that gets resolved properly (like things it would need the asset manager for). I don’t remember for sure.

There is no way to know the correct root for a particular j3o, though… unless you saved it with a consistent root in the first place.

1 Like