# [java] Cant find the file!

This topic is 3986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've got simple game which is loading its level from txt file as tilemap. Level just call method loadMap(String file) which start looks like this:
BufferedReader reader = new BufferedReader(new FileReader(subor));
while (true)
{
// If reader hit the end of file
if (line == null)
{
break;
}

After this method is searching in file and depend on founded charakter it load for example wall etc - not important. I've compiled it to jar file and start it home and it works. Then I've tried to start it on 2 another computer but it doesnt work. It couldnt find the file. It says that System cannot find the file. File is in folder res . I call method wit parameter "res/level.txt". As I said it works on my pc but on the other the IOException is thrown. I've tried to copy res folder on every place in jar file of my game but it doesn't work. I dont know where is problem and I need to show it in school tomorrow so I've only a little time. Please help :(. Btw in res folder are another files like pictures and with them there is no problem (but there are loaded by another class and another way but parameter of method is same "res/filename")Maybe I've compiled it badly Iam using Eclipse fat jar plugin. Btw on every pc which I've tried it on are Windows xp with SP2 and Jre 1.6 (or jdk 1.6 for compile). Sorry about my english.

##### Share on other sites
Try to put your "res" folder in the same directory as your jar, and run it again.
And, you should consider deploying such resources along with your .jar - then, use getResource() and getResourceAsStream() to load your files.