Incremental Java builds in the Eclipse IDE on the Linux desktop usually compile only the code affected by changes since the last build. If compiled files are stale, cleaning and rebuilding a project discards its build results and regenerates them from the saved source.

The Clean… dialog can clean every project in the workspace. Selecting a single project in the dialog limits which project has its build state cleared.

Eclipse writes compiled Java classes to an output folder such as bin. Cleaning can empty that folder, so keep files you maintain by hand outside the build output.

Start with a previously built Java project open in Project Explorer and any source edits saved. The example uses the greeting project and bin/Greeting.class. If your compiled output folder is already visible, start with step 5.

Steps to clean and rebuild a project in Eclipse:

  1. Open Filters and Customization using the funnel button in the Project Explorer toolbar.
  2. Enter output in the Pre-set filters search field, replacing any existing text.
  3. Clear Java output folders if it is checked.
  4. Click Apply.
  5. Expand your project in Project Explorer if it is collapsed.
  6. Expand your project's output folder if it is collapsed.

    The default folder for a Java project with separate source and output folders is bin. Your project can use another location.

  7. Note the name of a .class file that corresponds to a source file still in your project.
  8. Select your project's name in Project Explorer.
  9. Open the Project menu.

    The checkmark next to Build Automatically shows whether it was on before the clean. That starting setting determines whether step 18 applies.

  10. Turn off Build Automatically if it is checked.

    Pausing automatic builds lets you see the output disappear before you rebuild.

  11. Open Project > Clean….
  12. Clear Clean all projects if it is checked.
  13. Verify that only your project is checked in the Clean dialog.
  14. Clear Start a build immediately if it is checked.
  15. Click Clean.
  16. Confirm that the .class file you noted is gone from the output folder.

    The status bar shows progress while Eclipse cleans the project.

  17. Choose Project > Build Project.

    If the status bar shows build progress, wait for the indicator to disappear before continuing.

  18. Turn Project > Build Automatically back on if it was on before the clean.
  19. Confirm that the same .class file is back in the project's output folder after the build finishes.
Share this guide