6

Is there a command line way to invoke the java code formatting feature of Eclipse? Also, is there a way to configure the way it formats the code via command line?

The goal is to have a common code formatting mechanism for the entire team and automate that step prior to check in of code.

user855
  • 19,048
  • 38
  • 98
  • 162

4 Answers4

6

ajay try this post, there are some step-by-step instructions included here.

Kyle
  • 4,202
  • 1
  • 33
  • 41
1

Have a look at the JDT application org.eclipse.jdt.core.JavaCodeFormatter.

I haven't tried this out, but you should be able to start eclipse as

eclipse -application org.eclipse.jdt.core.JavaCodeFormatter -all...other...options

See org.eclipse.jdt.core.formatter.CodeFormatterApplication for the available options.

Tonny Madsen
  • 12,628
  • 4
  • 31
  • 70
-1

You can create specific format xml and whole team can use that Windows/Preference/java/formatter/Configure project specific setting , here we can edit and create customized format xml .Others can import this xml . Not very sure about command line

Kavitha
  • 461
  • 2
  • 8
  • 22
-1

I know of no way from command line. Have you looked at Save Actions?

Preferences => Java => Editor => Save Actions let you format all code whenever it's saved. If everyone uses Eclipse, you can distribute your standard formatting XML file and use Save Actions to take the manual step out of formatting.

The downside, of course, is that everyone has to use the same project settings.

Jonathon Faust
  • 12,396
  • 4
  • 50
  • 63