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

(Continued from page 1)

In my editor window, I have a TestServlet.java file that I had previously formatted with the built-in EclipseSW formatting settings.

TestServlet in Java Editor

I hit Control-Shift-F to format the TestServlet.java file according to the new "myprofile" profile. Notice that the line wrapping is now different since I changed the "Maximum line width" from 80 to 120.

TestServlet formatted according to 'myprofile'

Profiles are a nice feature that allow for customized code formatting so that you can format your code the way you like it. Profiles are particularly useful in a team development environment since they allow multiple developers to format their code according to the same formatting rules. This is very handy when it comes to formatting version-controlled files, since it prevents unnecessary file changes as a result of different developers applying different formatting rules to the same file.

Page: < 1 2