Reputation: 170
So I've created a game, runs perfectly in eclipse--all of the images load and it reads properly from a text file. The text file provides level info. This is where my problem comes in. I exported it all to an executable .jar file, and it found all of the images. But it did not find the .txt file. Where does the .txt file need to be for it to be found?
try{
controlBoard = new Scanner(new FileInputStream("lvl1.txt"));
}catch(Exception e){
gb.error = true;
}
Upvotes: 4
Views: 858
Reputation: 308998
You should not access that file using FileInputStream
. Get an InputStream
using the class loader and getResourceAsStream()
. It'll find it in the JAR.
Upvotes: 6