Re-building a deleted class file in Eclipse

前端 未结 5 1069
Happy的楠姐
Happy的楠姐 2021-02-09 18:33

I accidentally deleted a .class (Java bytecode) file in my project (on the filesystem, not using Eclipse itself). Easy to fix, right? Just re-build it. But that doesn\'t work! E

5条回答
  •  梦毁少年i
    2021-02-09 19:24

    You sure this source file is in your project's source set? Because Eclipse will only compile and put it in your classpath in that case. Right click the project in Package Explorer, Properties -> Java Build Path -> Source. The enclosing folder should be there or Eclipse won't compile it.

    In case, say, this source file of yours was once in source set and was compiled that could explain why it was working up until you removed the binary.

    In order for this problem not to happen I suggest having Scrub output folders when cleaning projects being selected in Java -> Compiler -> Building and Build automatically... on in Project menu.

    Also make sure your project compilation/build succeeds, otherwise Eclipse may not compile all the classes.

    If it still doesn't help it could be important what type of project you are having problems with: Java Project, Maven Project, Gradle Project, etc.

提交回复
热议问题