[英]No such file or directory Eclipse Java Mac OSX
I keep getting this error every time I run my OpenGL program and try and set up a texture: 每次运行OpenGL程序并尝试设置纹理时,我都会收到此错误:
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. 我在同一文件夹中有文件bricks.gif,它也出现在Eclipse中,但我不知道发生了什么。 I tried to clean and refresh as well, but nothing. 我试图清理和刷新,但没有。
Any help would be greatly appreciated. 任何帮助将不胜感激。
Two ideas for solving your problem: 解决问题的两个想法:
Make the reference to bricks.gif absolute, adding the full path. 参考bricks.gif absolute,添加完整路径。 (eg /Users/abc/workspace/bricks.gif) (例如/Users/abc/workspace/bricks.gif)
When Eclipse starts your Application, the directory root will be your project folder. 当Eclipse启动您的应用程序时,目录根目录将是您的项目文件夹。
Think of the following layout in Eclipse Package Explorer: 考虑Eclipse Package Explorer中的以下布局:
projectname
-src
-bin
-...
-bricks.gif
You can refer to the file in relative way by using the path "./bricks.gif". 您可以使用路径“./bricks.gif”以相对方式引用该文件。 You can obtain a File Object pointing to bricks.gif with the following code: 您可以使用以下代码获取指向bricks.gif的文件对象:
File bricks = new File("./bricks.gif");
or 要么
File bricks = new File("bricks.gif");
Cheers 干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.