Reputation: 3115
I keep getting this error every time I run my OpenGL program and try and set up a texture:
Unable to read texture file: java.io.FileNotFoundException: bricks.gif (No such file or directory)
I have the file bricks.gif in the same folder and it shows up in Eclipse as well, but I have no idea what is going on. I tried to clean and refresh as well, but nothing.
Any help would be greatly appreciated.
Upvotes: 1
Views: 4733
Reputation: 1392
Two ideas for solving your problem:
Make the reference to bricks.gif absolute, adding the full path. (e.g. /Users/abc/workspace/bricks.gif)
When Eclipse starts your Application, the directory root will be your project folder.
Think of the following layout in Eclipse Package Explorer:
projectname
-src
-bin
-...
-bricks.gif
You can refer to the file in relative way by using the path "./bricks.gif". You can obtain a File Object pointing to bricks.gif with the following code:
File bricks = new File("./bricks.gif");
or
File bricks = new File("bricks.gif");
Cheers
Upvotes: 4