SeleniumTester
SeleniumTester

Reputation: 313

Google -java-format Code formatter for java Intellij

I installed google-java-format in Intellij and made sure its enabled for current project. However its still not working, CTRL+ALT+L, which is by default in Intellij is still working.

Also, does this formatter shows error if formatting is wrong. Like eslint shows error if you leave trailing space in vs code.

Or anyone can suggest better formatter or any other way, guidance is appreciated. Though i make sure to do CTRl+ALT+L before pushing code, if my editor can highlight it in case i miss it, it would be great.

Thanks !!

Upvotes: 1

Views: 3170

Answers (1)

sampathlk
sampathlk

Reputation: 338

Feb 2023 with the latest google-java-format Intellij plugin we need to add following custom VM options. ( Go to Help -> Edit Custom VM Options )

-Xmx2018m
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

Just follow the updated README file. Updated README file

Upvotes: 2

Related Questions