• Advertisement
Sign in to follow this  

Whats wrong?

This topic is 2005 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i recently have encountered an error when i compile my game in eclispe and it started happening this afternoon
Exception in thread "main" java.lang.NullPointerException
at javagame.Game.initStatesList(Game.java:25)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:164)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
at javagame.Game.main(Game.java:34)

Share this post


Link to post
Share on other sites
Advertisement
Can you post the code from Game.java at line 25 (+ context, not just this line) ?

Share this post


Link to post
Share on other sites
Without any code or even any hint about what you're doing exactly we can't help you

When you encounter an error please post the code in which your error is occuring, mark the line of code where the code crashed, and give a description of what you're trying to do exactly.

Share this post


Link to post
Share on other sites
package javagame;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Game extends StateBasedGame{
public static final String gamename = "Bucky's World!";
public static final int menu = 0;
public static final int play = 1;
public static final int play2 = 2;

public Game(String gamename){
super(gamename);
this.addState(new Menu(menu));
this.addState(new Play(play));


}

public void initStatesList(GameContainer gc) throws SlickException{

this.getState(menu).init(gc, this);
this.getState(play).init(gc, this);
this.getState(play2).init(gc, this);
this.enterState(menu);
}

public static void main(String[] args) {
AppGameContainer appgc;
try{
appgc = new AppGameContainer(new Game(gamename));
appgc.setDisplayMode(640, 360, false);
appgc.start();

}catch(SlickException e){
e.printStackTrace();
}
}
}

Share this post


Link to post
Share on other sites
when i open the classes it says "Source not found" Edited by rip-off
Please do not remove useful content from threads without good reason

Share this post


Link to post
Share on other sites
You've added two states to the list in the constructor, but in the initStatesList function you seem to be trying to initialise 3 states.

Share this post


Link to post
Share on other sites
Is your intention to get rid of the JVM completely? In this case you would have to compile the Java sources to native code. I believe gcc can do that within certain limitations.
If you just want to hide the bytecode from the end user, there are several wrappers like http://launch4j.sourceforge.net/ which just fell out of Google.

Share this post


Link to post
Share on other sites
As I said, gcc can probably do it. I would ask why though. A decent, modern JVM can do some pretty neat optimizations at runtime which a static compiler just cannot do.

Share this post


Link to post
Share on other sites
You have to compile your code into a .jar file.

Here is a tutorial: http://www.horstmann.com/bigj/help/compiler/tutorial.html

Btw: Google is the programmers main tool.
You find many good tutorials, Q&A sections and documentations for java related stuff, try finding them with google, they will help you with many problems and questions you encounter in your programming life.

Share this post


Link to post
Share on other sites

I want to get rid of the JVM completely


Why?


btw im really noob
[/quote]

Okay, so in that case you don't to get rid of the JVM. Just launch4j if you want to create an exe. Otherwise, you can still just execute .jar files (hell, I think Minecraft still works this way doesn't it?).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement