Java Package Formatter

When you want to format multiple Java source in Eclipse the only way is to open each and every file, right click in the editor window, select the "Format" option, and save the formatted file.

Java Package Formatter

Java Package Formatter

     

When you want to format multiple Java source in Eclipse the only way is to open each and every file, right click in the editor window, select the "Format" option, and save the formatted file. This plugin allows you to select one or more packages in the Java Package Explorer and format all .java files in those packages. You can also choose to select just the specific Java source files you wich to format or even the whole source directory.

N.B.: This functionality comes standard in Eclipse 3.0 and up. I won't be creating any new versions, but these versions will be available for those stuck on an older version of Eclipse, e.g. those using IBM WebSphere Application Developer 4.0, 5.0 or 5.1.

Installation

To install this plugin, follow these steps:

  1. Make sure you have Eclipse 2.0.0 or higher.
  2. Exit Eclipse.
  3. Download the ZIP file that contains the plugin.
  4. Extract the contents of the ZIP file into the plugins directory of your Eclipse installation.
  5. When the files have been extracted verify that the plugin configuration file can be found at ...\eclipse\plugins\org.klomp.eclipse.formatjava_1.0.1\plugin.xml.
  6. Start Eclipse.

Usage

To use the plugin, go to the Package Explorer (usually found in the Java Perspective) and select one or more of the following:

  1. Java source files,
  2. Java packages, or
  3. Java source folders (usually called "src").
and press the right mouse button. Then select "Format .java files" from the popup menu that appears.

 

The selected packages and source folders will be scanned for Java source files. The Java source files and those selected by the user are then formatted. If any of those Java source files has already been opened in an editor window, the contents of that window are formatted. If the window had unsaved changes, the contents are not saved to disk.

Click on this link to get more detail: http://www.klomp.org/formatjava/