Java 如何通过 Eclipse 获取类文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2280176/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 05:37:27  来源:igfitidea点击:

How to get a class file by Eclipse?

javaeclipsebuildrefresh.class-file

提问by Roman

I wrote an application in the Eclipse, which was successfully compiled and run. After that, in a corresponding directory I found *.java and *.class files. Then I have deleted the *.class file and now I do not know how can I get it back.

我在Eclipse中写了一个应用,编译运行成功。之后,在相应的目录中我找到了 *.java 和 *.class 文件。然后我删除了 *.class 文件,现在我不知道如何取回它。

Eclipse writes me "A class file was not written. The project may be inconsistent, if so try refreshing this project and building it".

Eclipse 写给我“没有编写类文件。项目可能不一致,如果是这样,请尝试刷新此项目并构建它”。

By the right click on the project I got a drop down menu in which I found "Refresh" but I cannot find out how can I "build" the project.

通过右键单击项目,我得到了一个下拉菜单,在其中找到了“刷新”,但我不知道如何“构建”该项目。

So, how can I generate the class file again?

那么,我怎样才能再次生成类文件呢?

Thank you in advance for any help.

预先感谢您的任何帮助。

采纳答案by Thomas Jung

  1. Cleaning the project should be enough to start the build. Menu:Project ->Clean
  2. Check that automatic build is enabled. Project -> Build Automatically
  3. If automatic build is disabled use build all. Menu: Project -> Build All
  1. 清理项目应该足以开始构建。菜单:项目 -> 清洁
  2. 检查是否启用了自动构建。项目 -> 自动构建
  3. 如果禁用自动构建,请使用全部构建。菜单:项目 -> 全部构建

回答by PHZ.fi-Pharazon

I get this error message when I have an inner class, and the total name of the main class and its inner classes exceeds 128 characters. This happens both on OpenJDK and Sun JDK 6. The solution for me was to shorten the inner class names.

当我有一个内部类,并且主类及其内部类的总名称超过 128 个字符时,我收到此错误消息。这在 OpenJDK 和 Sun JDK 6 上都会发生。我的解决方案是缩短内部类名。