18 replies to this topic
#1 Members - Reputation: 105
Posted 25 July 2012 - 03:15 AM
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)
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)
Ad:
#2 Members - Reputation: 4604
Posted 25 July 2012 - 03:19 AM
Can you post the code from Game.java at line 25 (+ context, not just this line) ?
Ashaman
My game: Gnoblins
Developer journal about Gnoblins
Small goodies: Simple alpha transparency in deferred shader
My game: Gnoblins
Developer journal about Gnoblins
Small goodies: Simple alpha transparency in deferred shader
#3 Members - Reputation: 2043
Posted 25 July 2012 - 03:21 AM
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.
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.
#4 Members - Reputation: 105
Posted 25 July 2012 - 03:46 AM
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();
}
}
}
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();
}
}
}
#9 Members - Reputation: 1396
Posted 25 July 2012 - 04:53 AM
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.
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.
#15 Crossbones+ - Reputation: 1061
Posted 25 July 2012 - 06:47 AM
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.
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.
Project: Project
Setting fire to these damn cows one entry at a time!
Setting fire to these damn cows one entry at a time!
#18 Members - Reputation: 419
Posted 26 July 2012 - 11:48 AM
I want to get rid of the JVM completely
Why?
btw im really noob
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?).






