Is there an emacs tool to format java code according to a Java Code Formatter Profile (xml) spec, such as the one below?


I'm aware I could use an after-save-hook in java mode to invoke an external tool, like eclipse, to achieve this, but I'd like to know if there is a native emacs tool.

1 Answer 1


You can do that using https://github.com/emacs-lsp/lsp-java by setting lsp-java-format-settings-url to https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml

(setq lsp-java-format-settings-url "https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml")

Edit: the correct url must be raw https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.