Java 在 Eclipse 中重新创建项目的“bin”文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23891459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Recreating a project's "bin" folder in eclipse
提问by Hele
My Portable hard drive was damaged recently, on which I had my Eclipse workspace, but during the (expensive) recovery process, it was partially recovered. I have most of my source, but it happens that a project's bin file is empty. It was probably damaged.
我的便携式硬盘驱动器最近损坏了,我的 Eclipse 工作区在其上,但在(昂贵的)恢复过程中,它被部分恢复。我有我的大部分资源,但碰巧一个项目的 bin 文件是空的。它可能已损坏。
Now, I know that the bin file contains only .class files and I can probably regenerate them in a new project and move then to this bin. I may even be able to compile it via console and move it here, but since the project is big, is there any way to tell eclipse to recompile the classes and put them in the bin?
现在,我知道 bin 文件只包含 .class 文件,我可能可以在新项目中重新生成它们,然后移动到这个 bin。我什至可以通过控制台编译它并将其移动到这里,但是由于项目很大,有什么方法可以告诉 eclipse 重新编译这些类并将它们放入 bin 中?
I already tried using Project > Clean. It doesn't seem to regenerate them.
我已经尝试过使用 Project > Clean。它似乎没有再生它们。
Additional info :
附加信息 :
- The bin is empty. I cant see even the empty package folders there.
- For one thing, I'm not sure if that is the problem at all. What I really get is an error saying "Error: Could not find or load main class ut.rm.reader". But I noticed that other projects having the .class files in the bin work fine. So I'm taking a good guess that this is the problem.
- 垃圾桶是空的。我什至看不到那里的空包文件夹。
- 一方面,我不确定这是否是问题所在。我真正得到的是一个错误,说“错误:无法找到或加载主类 ut.rm.reader”。但我注意到在 bin 中有 .class 文件的其他项目工作正常。所以我很好地猜测这就是问题所在。
Thanks in advance.
提前致谢。
采纳答案by Alexandre Santos
These answers are really good and to the point. If they could not help you it is probably because your .project file is damaged. Try this:
这些答案非常好,切中要害。如果他们无法帮助您,可能是因为您的 .project 文件已损坏。尝试这个:
Close your project and remove from the workspace (delete the project but not the physical files).
关闭您的项目并从工作区中删除(删除项目但不删除物理文件)。
Delete the .project file, which is in the root of the project you just closed.
删除 .project 文件,该文件位于您刚刚关闭的项目的根目录中。
Make a backup of your project (always a good idea)
备份您的项目(总是一个好主意)
In Eclipse, create a new project and copy the files into the new project. Make sure it is a Java project.
在 Eclipse 中,创建一个新项目并将文件复制到新项目中。确保它是一个 Java 项目。
As soon as you rebuild the project you should see the bin folder.
重建项目后,您应该会看到 bin 文件夹。
回答by Chris Gerken
This is a bit of a kludge, but go to the compiler settings for the project (configure build path) and make a change (e.g. change one of the Java Compiler -> Errors/Warnings from warning to error). When you click apply you'll be told you need to recompile the entire project. Once the project is recompiled (and your classes recreated), go back and undo the compiler setting you changed.
这有点麻烦,但是转到项目的编译器设置(配置构建路径)并进行更改(例如,将 Java 编译器 -> 错误/警告之一从警告更改为错误)。当您单击应用时,您会被告知需要重新编译整个项目。重新编译项目(并重新创建您的类)后,返回并撤消您更改的编译器设置。
回答by pebble
Delete bin folder.
删除 bin 文件夹。
Right Click on Project's Name and choose "Refresh" which will generate (empty)directory structure.
右键单击项目名称并选择“刷新”,这将生成(空)目录结构。
Run the project(Click on Play symbol).
运行项目(点击播放符号)。
回答by Chris Hagn
This may not be an issue with the current project but a project you are dependent on.
Right click on your project and Select: Build Path > Configure Build Path
这可能不是当前项目的问题,而是您依赖的项目。
右键单击您的项目并选择:构建路径 > 配置构建路径
Under the projects tab, check to see if any other projects are listed. You may need to resolve the Java Compiler settings or libraries in that project. If there is an issue with that project, there should be a "red exclamation" mark on that project.
在项目选项卡下,检查是否列出了任何其他项目。您可能需要解决该项目中的 Java 编译器设置或库。如果该项目存在问题,则该项目上应该有一个“红色感叹号”。
Make sure that your JRE environment is compatible with the external JAR files and dependent projects.
确保您的 JRE 环境与外部 JAR 文件和相关项目兼容。