Eclipse: Difference between clean, build and publish

37,892

Solution 1

When you run "project > Build" , eclipse will compile all sources in folders on the build path to the .class files and put the .class files into the output folder you specified. Both of these folders can be configured from Project-> Properties-> Java Build Path . Note that eclipse has the incremental build feature that will only compile the sources that have changed since the last time the project is build.

If you enable Auto-build for the project ( via "Project-> Build Automatically" ) , the "project > Build" will run automatically when you add, remove, or modify the source files on the build path , so you don't have to call "project > Build" manually in this case.

The Publish option in the server tab will deploy the application to your Tomcat instance by copying the project resources such as xml configuration files , web resource (html ,css, js etc) , and the compiled .class files you get from the "project > Build" to the correct location of the Tomcat instance .

So , "Project > Build" is about compiling java sources to the .class files while the options in the server tab is about deploying the application to the tomcat instance and maintaining the tomcat instance .

You can find the information about the "server tab" (i.e. Web Tools Platform) from the following links: http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.wst.server.ui.doc.user/topics/tpublish.html http://wiki.eclipse.org/WTP_Tomcat_FAQ

Solution 2

Build: compile changed source files on the build path in the project
Clean: compile all source files on the build path in the project
Publish: Deploying the updated project in the web server instance

Solution 3

Clean, Publish and Clean Tomcat Work directory options work on server files, on the other hand Project>build work on workspace files (projects are inside workspace folder). Server files and workspace files are usually in separated folders, it depends on how do you have configured your server.

Share:
37,892
Maro
Author by

Maro

Updated on July 09, 2022

Comments

  • Maro
    Maro almost 2 years

    I am using eclipse with tomcat. On the server (right-click)tab you have the options: Clean, Publish and Clean Tomcat Work directory, What do these options really do and how are they different from project > Build

  • Maro
    Maro about 13 years
    Thank you so much. Perfect answer.
  • armyofda12mnkeys
    armyofda12mnkeys over 11 years
    to add onto orig posters question since he asked about Servers->Clean, Whats the difference between Project->Clean and Servers->Clean?
  • miwe
    miwe almost 8 years
    Note: If after doing this, you see the error: "'Publishing to Tomcat v*.* Server at localhost...' has encountered a problem" run eclipse as admin