Hello,
when I try to execute the .jar file on Windows, I get this error:
Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
ArrayIndexOutOfBoundsException: Array index out of range: 0
It’s strange, because if I run on Linux, the game starts without problems.
So, since I use a Vector to store players infos I though that the error can be related.
Here’s some code:
[java]
public class myGame extends SimpleApplication implements AnalogListener{
private static Vector players;
public static void main(String args[]){
myGame application=new myGame();
players=new Vector();
initPlayersVector();
application.start();
}
// more code
}[/java]
And the initPlayersVector method:
[java]
static public void initPlayersVector()
{
int playersNumber;
String playerName;
System.out.println("How many players do you want to insert? ");
playersNumber=Read.readInt(); // Read is a custom class to read from keyboard
for(int i=0;i<playersNumber;i++){
System.out.println("Insert player name: ");
playerName=Read.readString();
players.add(new player(playerName,0)); // add a new player with name and score to vector
}
}
There isn’t any stack trace. The project build and run without problems on my main computer (which runs Linux). Only if I try to launch the jar file built in Linux I get the error.
@danieleM said:
There isn't any stack trace. The project build and run without problems on my main computer (which runs Linux). Only if I try to launch the jar file built in Linux I get the error.
P.S. As always, sorry for my poor english.
Then where did you see this:
Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
ArrayIndexOutOfBoundsException: Array index out of range: 0
If you aren’t seeing a stack trace then you need to improve your error reporting somehow. It is impossible for us to help without a stack trace. Just impossible.
Well, in my game I use the console to enter some data. And if I want to use the console, I have to run the .jar file with java -jar myGame.jar . I was simply double-clicking the file, so the console didn’t open and the vector remained empty.
That’s the reason of the error.