Jump to content
  • Advertisement
Sign in to follow this  
Pracka

[java] Cant find the file!

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

If you intended to correct an error in the post then please contact us.

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)
{
String line = reader.readLine();
// If reader hit the end of file
if (line == null)
{
reader.close();
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 this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!