Question

I'm new in java and J-monkey and I'm trying to make a java game so for the Menu I have made a enum so I can Switch between any of my State but I want to keep the main file shorter so it can be easily to read so I'm making subclass the problem is that when run the game it give me an error that say "Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] NullPointerException" I think this problem has to be something whit the pipeline Here is the code of my main file:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.font.BitmapText;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Spatial;
import com.jme3.scene.Geometry;

import com.jme3.input.*;
import com.jme3.input.controls.*;

public class Main extends SimpleApplication {

//GameStates
enum GameState{Logo, Menu, Playing, Option};
GameState gameState = GameState.Logo;

//Class Variables
Logo logo;


public Main() {

logo = new Logo();

}

public static void main(String[] args) {
    Main app = new Main();
    app.start();
}

public static void logo(String[] args) {
    Logo app = new Logo();
    app.start();
}

@Override
public void simpleInitApp() {
    //Load
    flyCam.setMoveSpeed(20);
    if(gameState == GameState.Logo){
        logo.simpleInitApp();
    }
}

@Override
public void simpleUpdate(float tpf) {

}

@Override
public void simpleRender(RenderManager rm) {
    //TODO: add render code
    //Load
    if(gameState == GameState.Logo)
    {

    }

}
}

And here is my Logo subclass:

package mygame;

    import com.jme3.app.SimpleApplication;
    import com.jme3.renderer.RenderManager;
    import com.jme3.scene.Spatial;

    public class Logo extends SimpleApplication {

    @Override
    public void simpleInitApp() {
    Spatial Logo_Model = assetManager.loadModel("Models/Teapot/Logo.obj");
    rootNode.attachChild(Logo_Model);
    }

    public void simpleRender(RenderManager rm) {
    //Load

    }
    }

I have move down the stack trace that I think is giving my problem so you don't have to read all the Exception just scroll down

Full Exception stack trace: Nov 09, 2013 11:29:32 AM java.util.prefs.WindowsPreferences WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5. Nov 09, 2013 11:29:49 AM com.jme3.system.JmeDesktopSystem initialize INFO: Running on jMonkeyEngine 3.0.0 Beta Nov 09, 2013 11:29:49 AM com.jme3.system.Natives extractNativeLibs INFO: Extraction Directory: C:\Users\Zero\Documents\Basic_Test_menu Nov 09, 2013 11:29:49 AM com.jme3.system.lwjgl.LwjglAbstractDisplay run INFO: Using LWJGL 2.8.4 Nov 09, 2013 11:29:49 AM com.jme3.system.lwjgl.LwjglDisplay createContext INFO: Selected display mode: 800 x 600 x 0 @0Hz Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: Adapter: igdumd64 Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: Driver Version: null Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: Vendor: Intel Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: OpenGL Version: 3.1.0 - Build 9.17.10.2932 Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: Renderer: Intel(R) HD Graphics Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: GLSL Ver: 1.40 - Intel Build 9.17.10.2932 Nov 09, 2013 11:29:50 AM com.jme3.system.lwjgl.LwjglTimer INFO: Timer resolution: 1,000 ticks per second Nov 09, 2013 11:29:50 AM com.jme3.renderer.lwjgl.LwjglRenderer initialize INFO: Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, OpenGL20, OpenGL21, OpenGL30, OpenGL31, ARBprogram, GLSL100, GLSL110, GLSL120, GLSL130, GLSL140, VertexTextureFetch, TextureArray, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, NonPowerOfTwoTextures, MeshInstancing, VertexBufferArray, Multisample, PackedDepthStencilBuffer] Nov 09, 2013 11:29:50 AM com.jme3.asset.AssetConfig loadText WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader Nov 09, 2013 11:29:50 AM com.jme3.asset.DesktopAssetManager INFO: DesktopAssetManager created. Nov 09, 2013 11:29:50 AM com.jme3.renderer.Camera INFO: Camera created (W: 800, H: 600) Nov 09, 2013 11:29:50 AM com.jme3.renderer.Camera INFO: Camera created (W: 800, H: 600) Nov 09, 2013 11:29:50 AM com.jme3.input.lwjgl.LwjglMouseInput initialize INFO: Mouse created. Nov 09, 2013 11:29:50 AM com.jme3.input.lwjgl.LwjglKeyInput initialize INFO: Keyboard created. Nov 09, 2013 11:29:51 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread INFO: AudioRenderer supports 64 channels Nov 09, 2013 11:29:51 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread INFO: Audio effect extension version: 1.0 Nov 09, 2013 11:29:51 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread INFO: Audio max auxilary sends: 4 Nov 09, 2013 11:29:51 AM com.jme3.material.MaterialDef INFO: Loaded material definition: Unshaded Nov 09, 2013 11:29:51 AM com.jme3.scene.Node attachChild INFO: Child (BitmapFont) attached to this node (null) Nov 09, 2013 11:29:51

AM com.jme3.app.Application handleError SEVERE: Uncaught exception
   thrown in Thread[LWJGL Renderer Thread,5,main]

   java.lang.NullPointerException
at mygame.Logo.simpleInitApp(Logo.java:17)
at mygame.Main.simpleInitApp(Main.java:46)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
at                com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:722)


    Nov 09, 2013 11:29:51 AM com.jme3.renderer.lwjgl.LwjglRenderer cleanup
    INFO: Deleting objects and invalidating state
    Nov 09, 2013 11:29:51 AM com.jme3.input.lwjgl.LwjglMouseInput destroy
    INFO: Mouse destroyed.
    Nov 09, 2013 11:29:51 AM com.jme3.input.lwjgl.LwjglKeyInput destroy
    INFO: Keyboard destroyed.
    Nov 09, 2013 11:29:51 AM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
    INFO: Display destroyed.
Was it helpful?

Solution

The problem is assetManager is null at that point in time. Either you assign it too late or you forget to assign it at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top