This article is reproduced from http://www.ibm.com/developerworks/cn/opensource/os-eclipse-clean/
But in order to adapt to their own use, or summed up a bit.
A Overview
Code Cleanup: Code cleanup is a very usability tool that makes your code look more comfortable and helps others to read. Eclipse allows you to clear the code, add missing code, and apply a style.
A specific cleanup configuration is referred to as a configuration file. The configuration file can be saved so that you can either give the configuration file to someone else or apply the earlier project and other people's settings to the current code. Profiles can be applied to all eclipse projects, making it easy to get the same code style across all development teams.
A code cleanup configuration file is built into eclipse. This file defines a minimal code cleanup.
You can basically delete unnecessary code and add some necessary comments. Built-in files cannot be changed.
Two How to use the default configuration file for code cleanup
For example, if I have the following classes (which introduce unused packages and override the ToString method without @override), then you can use the default configuration file for code cleanup: Choose right--->source--->cleanup and select Configured profiles, then press Next, then finish.
Two To create your own code cleanup configuration file
Select Windows--->preferences--->java--->clean up----->new to edit your own code cleanup configuration file. New one's own code cleanup configuration file, the open the Edit dialog now removed (see what others say) after you can press edit, edit their own code cleanup configuration file.
1. After you have pressed edit. To start the setup. Set code organizing: For me, it is more useful on the imports hook, you can only reference a useful package, no use can not be introduced.
2 Set the code Style, each has a role, you can click to see the right side of the preview, you will know where the difference, such as if parentheses, using JDK1.5 new addition to the enhanced for loop, parentheses, plus final. Final is required, can enhance the performance of the program and so on.
3. Set Member accesses, that is, add this. The personal feel is not very useful.
4. Set missing Code. Very useful. Usually the first and the third are hooked up.
5. Set the unnecessary. The general setting is the first one. The second third removes unused variables that I have previously set and found to be a bit of a hassle when I test for code. This is determined by the individual.
Finally, the setup is complete and the application is ready. Right-click--->source--->clean up app to change to:
Otherwise, you can export by pressing export all. Import can be introduced by others.
Ps: Perform cleanup on save, and in window--->preference--->java--->editor--->save Actions and select additional features. Then select the Configure configuration and you can.
Eclipse uses the Code cleanup feature (clean up)