aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes What does Project>Clean do in Eclipse? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "What does Project>Clean do in Eclipse?" Watch "What does Project>Clean do in Eclipse?" New topic
Author

What does Project>Clean do in Eclipse?

Ajay Dhar
Ranch Hand

Joined: Jan 26, 2011
Posts: 30
What does Project>Clean do in Eclipse? Sometimes I have to do this to remove the compile time errors from the screen and other times I have to do this to get my code running without runtime errors. I'm still not sure exactly what this does though. Any help is appreciated.

Thanks.


OCPJP 6, OCEEJBD 6, GIAC Secure Software Programmer-Java (GSSP-Java)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30546
    
150

It removes the .class files and recompiles the project. Basically, it forces a rebuild.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16068
    
  21

Jeanne Boyarsky wrote:It removes the .class files and recompiles the project. Basically, it forces a rebuild.


Almost. It removes the products, but the rebuild part is only automatic if you have automatic build turned on. Which is the default, but on occasion I have had to turn it off.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ajay Dhar
Ranch Hand

Joined: Jan 26, 2011
Posts: 30
Thanks for the replies. This is a basic question but what does it mean to build the project?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Ajay Dhar wrote:Thanks for the replies. This is a basic question but what does it mean to build the project?

For a Java project, it means compiling all Java classes.

From the documentation:

Java builder

The Java builder builds Java programs using a compiler that implements the Java Language Specification. The Java builder can build programs incrementally as individual Java files are saved.

Problems detected by the compiler are classified as either warnings or errors. The existence of a warning does not affect the execution of the program; the code executes as if it were written correctly. Compile-time errors (as specified by the Java Language Specification) are always reported as errors by the Java compiler. For some other types of problems you can, however, specify if you want the Java compiler to report them as warnings, errors or to ignore them. To change the default settings, use the Goto the Java compiler preference page Java > Compiler > Errors/Warnings preference page.

The Java compiler can create CLASS files even in presence of compilation errors. However, in the case of serious errors (for example, references to inconsistent binaries, most likely related to an invalid build path), the Java builder does not produce any CLASS files.


[My Blog]
All roads lead to JavaRanch
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16068
    
  21

To amplify on this a bit: If you look at your Project Properties dialog, you'll see a topic named "Builders". This is where the Builders for the project are managed. In a Java project, that will include the Java Builder. I have projects that also include a Maven Builder. In fact, you can design and incorporate custom builders into Eclipse as plug-ins, but that's more work than most of us want to do.

The builders are responsible for ensuring that whatever resources they manage are properly built. The Java builder watches over Java source folders and ensures that classes are recompiled as needed.

As I said earlier, building is normally automatic, although you can switch to manual operation of the builders if the situation requires it.

Builders handle the everyday low-level aspects of working with a project and its products, but they're not intended to do everything. Which is why Eclipse also supports specialized builds using Maven and Ant.
Scott Izu
Greenhorn

Joined: Oct 14, 2013
Posts: 1
It would help to know what Project->Clean actually does. Does it call 'mvn clean'?

Also, what does the build step do? Does it call 'mvn compile'?

The reason I am asking is I noticed that the build automatically will not filter my properties file. If I do 'mvn compile' the MAVEN_VERSION=${project.version} from the properties file in src/main/resources is copied to the target/class directory with the ${project.version} flag appropriately substituted. However, from Project->Clean, this does not happen.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16068
    
  21

No, Eclipse project clean doesn't run Maven. A Maven Clean is different.

Mostly Eclipse Clean is good for when Eclipse gets a scrambled idea of the state of the project.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What does Project>Clean do in Eclipse?