My Slick2D project seems to run okay when executed in the Eclipse IDE, but when I export it through JarSplice, it throws a NullPointerException
in the class 'Menu'.
Here is the snippet of code that throws the error:
@Override
public void render( GameContainer gc, StateBasedGame sbg, Graphics g ) throws SlickException {
g.setColor( Color.black );
g.setFont( Options.getGameFont() );
// Draw foreground objects.
{
g.drawString( "Start", 10, gc.getHeight()-50 ); // This line here
}
}
Along with the stack trace:
Sat Apr 18 17:20:59 BST 2015 ERROR:null
java.lang.NullPointerException
at org.newdawn.slick.Graphics.drawString(Graphics.java:1366)
at com.mgthomas.states.Menu.render(Menu.java:48)
at org.newdawn.slick.state.StateBasedGame.render(StateBasedGame.java:199)
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:688)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:411)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:321)
at com.mgthomas.Launch.main(Launch.java:48)
Sat Apr 18 17:20:59 BST 2015 ERROR:Game.render() failure - check the game code.
org.newdawn.slick.SlickException: Game.render() failure - check the game code.
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:691)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:411)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:321)
at com.mgthomas.Launch.main(Launch.java:48)
I have already added 'slick.jar' and 'lwjgl.jar', as well as all of the windows natives, to JarSplice, and it exports without any problems. However, when the exported .jar file is ran through the command prompt, the error above is displayed.