Sign in to follow this  

Whats wrong?

This topic is 1966 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
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
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 [url="http://launch4j.sourceforge.net/"]http://launch4j.sourceforge.net/[/url] 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
[quote name='Dr Lazy Bean' timestamp='1343213726' post='4962887']
I want to get rid of the JVM completely
[/quote]

Why?

[quote]
btw im really noob
[/quote]

Okay, so in that case you [i]don't[/i] 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

This topic is 1966 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this