找不到Eclipse文件?与JCreator合作 [英] Eclipse Files Not Found? Works with JCreator

查看:88
本文介绍了找不到Eclipse文件?与JCreator合作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯,我在JCreator中有这些.java文件。



当我在JCreator中编译它们的时候,很好,所有的文件和文件夹被读取,没有发生错误。但是,我需要在Eclipse项目中编译它们,以将其传递给我的教授。然后问题开始了。



我将新的Eclipse项目中的.java文件添加到

  src文件夹

然后,我做了项目中的新文件夹名为

  res 

,并将其作为源文件夹添加到构建路径,并在其中添加文件和文件夹。

 >用作源文件夹

所有子文件夹都是同名的东西,刷新项目几次,检查构建路径,但是当我执行程序时,它说:

  java.io. FileNotFoundException:sounds\bgmusic.wav(系统找不到指定的路径)

  InputStream test = new FileInputStream(sounds\bgmusic.wav); 

相同的文件夹名称,相同的文件,将其添加到构建路径和东西。另外,我重复一遍,它没有找到资源文件夹中的所有文件:图片,声音字体和其他东西。我已经在Eclipse中做了一些项目,我已经成功地添加了图片和声音。但这是什么问题?



感谢您的帮助!

解决方案

尝试这样:



ClassLoader.getResourceAsStream(sounds \\ bgmusic.wav);



我希望解决您的问题。



您还可以参考以下链接:



http://www.javaworld.com/article/2077352/java-se/smartly-load-your-properties.html


Well I have these .java files in JCreator.

When I compile them in JCreator, it's fine, all files and folders are read and no errors occurred. But, I need to compile them in an Eclipse project to pass it to my professor. Then the problems started.

I added the .java files in a new Eclipse project and into a new package inside the

   src folder

Then after that, I made a new Folder in the project called

   res

and added it to the build path as a source Folder and added the files and folders in it.

   >Use as Source Folder

All sub-folders are fine same name and stuff, Refreshed the project a few times, checked the build path, but when I execute the program, It says:

   java.io.FileNotFoundException: sounds\bgmusic.wav (The system cannot find the path specified)

from this line:

   InputStream test = new FileInputStream("sounds\bgmusic.wav");

Same folder name, same file, added it to the Build Path and stuff. Also, I repeat, It does not find ALL the files in the resource folder: Pictures, Sounds Fonts and other stuff. I already made some projects in Eclipse and I had successfully added pictures and sounds in them. But what's the problem with this?

Thanks for the help!

解决方案

Try this:

ClassLoader.getResourceAsStream ("sounds\bgmusic.wav");

I hope it resolves your issue.

You can also refer below link:

http://www.javaworld.com/article/2077352/java-se/smartly-load-your-properties.html

这篇关于找不到Eclipse文件?与JCreator合作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆