I built a game a while ago in eclipse. I wanted to export it like usual to a .jar. I've done this before and with my other projects it works. This one doesn't work because it gives a blank white screen. I put in a System.exit(1) on a different spots to see where the program stops working. Eventually I found the spot. It can't seem to locate my .txt file but in eclipse if does work. I've checked the .jar with 7zip(like winzip) and the .txt file is in there. I also used the command line to open it and it gives the same error of not being able to locate the .txt file. I've looked a lot on the internet and stackflow for people that have same questions of related problems but they didn't offer a fix unfortunately.
The code that make a new world is this.
world = new World(handler,"res/worlds/world1.txt");
In the world it calls this funtion:
loadWorld(path);
This funtion should return back a string. First it calls another function to get that string:
String file = Utils.loadFileAsString(path);
Finally this is the code that doesn't work because the file can't be located.
public static String loadFileAsString(String path){
StringBuilder builder = new StringBuilder();
try{
BufferedReader br = new BufferedReader(new FileReader(path));
String line;
while((line = br.readLine()) != null)
builder.append(line + "\n");
br.close();
}catch(IOException e){
e.printStackTrace();
}
return builder.toString();
}
Is there something that I missed? Eclipse runs it fine but after exporting its like the .txt isn't exported but it is still there. Thanks in advance.