1

This might be a simple question.

I have many images for my game that I am making. I dont want to place them in the root MyGame/ directory. I want to place them within a package, or folder inside the root Directory eg MyGame/Images/"img1.png"

Everytime I try to do that I get invalid path name no such file or directory. The only time it works is when the images are in root directory. I've tryed "MyGame/Images/"img1.png"/ and variants with leading slashes and can't get it to work.

Fixed. I needed to have a folder called resources and inside that have a folder called images.

hakre
  • 193,403
  • 52
  • 435
  • 836
straykiwi
  • 538
  • 6
  • 23
  • Why do you need the double quotes around "img1.png"? – davidXYZ Sep 26 '12 at 03:40
  • I hope this [answer](http://stackoverflow.com/a/9866659/1057230) might can help you in that. More specific answer being [this](http://stackoverflow.com/a/9278270/1057230) For one working example you can try [this one](http://stackoverflow.com/a/11372350/1057230) – nIcE cOw Sep 26 '12 at 03:42
  • I have tried to explain some steps here also, [on this link](http://gagandeepbali.uk.to/gaganisonline/webpages/makejareclipse.html) – nIcE cOw Sep 26 '12 at 03:55
  • Please add your solution as an answer below and accept it later (yes that works, and yes we love you to do that on this site). This will not only tell that your question has an answer, but also mark it as resolved (instead of editing the title which is only of limited help for this site). Thank you! – hakre Sep 26 '12 at 07:43

2 Answers2

0

Try to go up one level and then into your Images folder. Try

..\Images\img1.png
davidXYZ
  • 719
  • 1
  • 8
  • 16
0

Use a resource folder.

Inside root, make a folder called resources, and inside resouces put images.

So your filepath should be File f = new File("images/img0.png");

when the 'real' file path is root/resources/images/img0.png

straykiwi
  • 538
  • 6
  • 23