Eclipse 中的 Java:自动生成 .class 文件

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

Java in Eclipse: generating .class file automatically

javaeclipse

提问by qzar

when I change my foo.java file in Eclipse there are no changes in the foo.class inside the bin folder.

当我在 Eclipse 中更改 foo.java 文件时,bin 文件夹内的 foo.class 没有任何更改。

I think there must be a way that Eclipse change this automatically when altering an foo.java file?

我认为必须有一种方法可以让 Eclipse 在更改 foo.java 文件时自动更改它?

I even can't make it manually.

我什至无法手动完成。

Hope you can help me.

希望您能够帮助我。

Thanks

谢谢

回答by skaffman

  • Make sure it's a java project
  • Make sure the java file is in a source folder (right click project, properties, build path)
  • Make sure you have automatic build turned on (Project menu -> Build automatically)
  • 确保它是一个java项目
  • 确保 java 文件位于源文件夹中(右键单击项目、属性、构建路径)
  • 确保您已打开自动构建(项目菜单 -> 自动构建)

回答by BigFish

I know this is an old post, but I wanted to contribute in case someone else comes across this problem. When I experienced this problem (today) the build path looked good, class path looked good, default output directory was good, Java compiler looked good, but nothing. Then I selected Project, Properties, Builders and it said the builder was missing...the builder was incorrect. I removed the missing builder, opened the .project file (you may have to adjust the navigation filters to see this) and added:

我知道这是一篇旧帖子,但我想贡献一下,以防其他人遇到这个问题。当我遇到这个问题时(今天),构建路径看起来不错,类路径看起来不错,默认输出目录很好,Java 编译器看起来不错,但什么都没有。然后我选择了项目、属性、构建器,它说构建器丢失了......构建器不正确。我删除了缺少的构建器,打开了 .project 文件(您可能需要调整导航过滤器才能看到这一点)并添加:

    <buildCommand>
        <name>org.eclipse.jdt.core.javabuilder</name>
        <arguments>
        </arguments>
    </buildCommand>

inside the buildSet tags, and viola everything works. Hope this helps someone.

在 buildSet 标签内,中提琴一切正常。希望这可以帮助某人。

回答by Jolly1234

One of the other most important things people forgot to mention is that you also need to check the "problems" view to make sure there are not errors in your project. To view problems:

人们忘记提及的其他最重要的事情之一是您还需要检查“问题”视图以确保您的项目中没有错误。查看问题:

Window -> show view -> Problems

窗口 -> 显示视图 -> 问题

If there are 'Errors' you need to correct those before the eclipse can compile.

如果存在“错误”,您需要在 Eclipse 编译之前更正这些错误。