How do I create a profile to format Java code in Eclipse?
Author: Deron Eriksson
Description: This tutorial shows how to create a profile to format Java code in Eclipse.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)

Page:    1 2 >

EclipseSW has a very useful feature for formatting JavaSW code. You can create a formatting "Profile", which is essentially a collection for customized code formatting settings. You can have different profiles so that you can switch between formats, although I typically just stick with one format. In addition, a profile can be exported and imported so that a team of developers can all share the same formatting profile.

To create a new profile, you can go to Window → Preferences and go to Java → Code Style → Formatter. Click the New button.

New Profile

I created a profile called "myprofile", based on the built-in Eclipse profile.

Creating profile called 'myprofile'

I brought up the profile editor. I clicked on the Line Wrapping tab and changed the "Maximum line width" from 80 to 120. I clicked OK.

Changing Maximum line width

I clicked OK in the Formatter preferences to close the Preferences window.

Clicked OK

(Continued on page 2)

Page:    1 2 >