r/java • u/Lucky_Psychology8275 • Oct 25 '26
What cli formatter do you use
Given how software engineering evolves, using IDEA formatter is less and less practical.
- IDEA CLI formatter requires IntelliJ so no CI / wsl etc
- GJF is old and does not format lambdas well enough
- Palantir is obsolete and abandoned in addition to being one of the worst company ever created
- prettier-java not great either
I’m starting to think no formatter is the best option
24
Upvotes
11
u/kevinb9n Oct 25 '26
> GJF is old and does not format lambdas well enough
Liam is still at it. This landed last week
https://github.com/google/google-java-format/issues/19#issuecomment-6214823566
11
u/_predator_ Oct 25 '26
The palantir formatter is neither obsolete nor abandoned. I'm using it in multiple projects and am quite happy with it.
Do I like the company making it? No, but I also don't like Apple, Google, Amazon, or Microsoft, yet here I am using their products every single day. And in contrast to the other companies' products, Palantir gains nothing from me using a free code formatter, lol.
The formatter landscape in Java is quite shit, and Palantir's is the only one that doesn't make my eyes bleed.
5
u/bokchoi Oct 25 '26
https://github.com/bmarwell/jfmt is a cli formatter that uses the Eclipse formatting tool but compiled with graal so it starts and runs fast enough for cli usage.
5
u/ForeverAlot Oct 25 '26
It formats lambdas just fine. And unlike some of its competitors, it is quick to add minimal support for new syntax. It's a really solid bet in practice.
I'm not affiliated with GJF but I've been a happy user for many years.
9
u/r_n_c Oct 25 '26
Spotless and eclipse config. Note we add a dependency to the spotless plugin so we can have a remote configuration shared amongst many of our projects.
14
u/4r73m190r0s Oct 25 '26
Google Java Format https://github.com/google/google-java-format
8
u/Fluffy_Dragonfly6454 Oct 25 '26
Spotless with Google formatter works like a charm
4
u/junin7 Oct 25 '26
Spotless
3
u/raxel42 Oct 25 '26
Whatever, just use to minimize git diff
3
u/Zardoz84 Oct 27 '26
Eclipse formatter as maven pluggin
5
u/blazmrak Oct 25 '26
Eclipse with a lot of custom config via Spotless.
3
u/un_desconocido Oct 25 '26
Spotless and Palantir format, I hooked it up to the maven build so nobody needs to do a git hook.
2
u/doobiesteintortoise Oct 25 '26
Spotless is what I use.
2
u/jonenst Oct 25 '26
Never tried it but recently someone mentionned here the new kid in town Netflix jfmt https://github.com/Netflix/jfmt
1
u/jevring Oct 25 '26
The Google one is without a doubt the ugliest I have ever had the misfortune of reading. We use an intellij idea setup. I wouldn't want one that isn't integrated into our IDE. You can run the intellij formatter on the command line, but you need the whole ass ide for it. We do that for validation in ci/cd.
1
u/SamirAbi Oct 26 '26
What is your issue with prettier?
1
u/agentoutlier Oct 27 '26 edited Oct 27 '26
Spring has a Java formatter that uses the Eclipse formatter headless.
It uses tabs which I prefer.
Likewise there is maven plugin that will use eclipse formatter as well that I nice been probably using for a decade now:
https://code.revelc.net/formatter-maven-plugin/
Most of the good ones use Eclipse.
1
u/Ok_Elk_638 Oct 29 '26
Whatever the Intellij default is. I don't like automating this, automatic formatters always make my code worse.
0
u/lazystone Oct 25 '26
https://github.com/palantir/palantir-java-format/
But why do you say that it's abandoned(no objections about the company itself though)?
There is also a fork of PJF: https://github.com/openjavaformat/open-java-format but I haven't looked who is behind it.
0
u/sg-elide Oct 25 '26
elide supports GJF, Kotlin fmt, and will shortly support Netflix’ GJF dialect as well, which is very popular. all run in native so they are extremely fast. like milliseconds.
https://elide.help has more info
-2
u/MyStackOverflowed Oct 25 '26
Google or palantir, the palantir one handles lambdas better
-5
u/patoessy Oct 25 '26
RemindMe! 1 day from now
-5
u/DanLynch Oct 25 '26
We use a custom configuration of the IntelliJ IDEA formatter, and try to enforce it in the CI with Checkstyle and Spotless, but it's not a perfect match.