assetManager in a class not extending Application

Hello, I’m new to the forum and obviously new to the jMonkeyEngine3. If that matters, I’m using the nightly builds.

The problem is as in the title: the same line that works in Main doesn’t in a different class. I have an AssetManager field but the line

[java]Material mat = new Material(assetManager, “Common/MatDefs/Misc/SimpleTextured.j3md”);[/java]

throws a NullPointerException. What should I do?

Thanks in advance.

could you post the complete stack trace please?

This line can hardly throw that kind of exception.

Yup, sorry for not posting it in my previous post, I thought it was some kind of common noob mistake:

2011-02-20 11:22:50 handleError

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


at com.jme3.material.Material.(

at mygame.Cor.makeWall(

at mygame.Cor.r(

at mygame.Main.simpleInitApp(


at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(



ok you assetManager is null.

where do you call it? do you use SimpleApplication?

No, my assetManager is in the class Cor that doesn’t extend anything. I guess I should use assetManager.registerLocator(); but I’m not sure what are those parameters it takes.

no you should pass the assetManager to the Cor class from the simpleApplication.

what do you do then?

AssetManager assetManager;

Material mat = new Material(assetManager, “Common/MatDefs/Misc/SimpleTextured.j3md”);


1 Like

I used this method getAssetManager(); and made a new method that returned assetManager but both gave me the same stack trace.

If you just put a field there its null. You have to assign a value to it… So in the constructor of the class you go something like:


public MyClass(AssetManager manager){




1 Like

Thanks guys, it’s working now!