Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard. (http://checkstyle.sourceforge.net/)
Update checkstyle jar
You can use the built-in flymake to run the checkstyle in the background as you edit your file. Add this to your ~/.emacs file and change the path to the jar and conf
;; Check style of Java files.
(add-hook 'find-file-hook 'flymake-find-file-hook)
(defun flymake-java-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
(cons '("\\(.*\\.java\\):\\([0-9]+\\):[0-9]+: \\(.+\\)" 1 2 nil 3)
;; Check *Message* buffer for errors. If you don't find any, you can remove this line.
(setq flymake-log-level 3)
Flymake will underline lines with errors and warnings. In GUI mode, Emacs will show a tooltip when you hover your mouse over the underlined lines. Setup a shortcut to go to the next error:
;; Go through flymake errors with F4. Show the tooltip with F3. (Tooltips work only in GUI mode.)
(global-set-key [f4] 'flymake-goto-next-error)
(global-set-key [f3] 'flymake-display-err-menu-for-current-line)
You can use the built-in C-h . (Control-h period) shortcut to show the error from the current line in the minibuffer when in running Emacs in a terminal. Alternatively, you can configure Emacs to show the error in the minibuffer after a short delay of your cursor being in that line:
;; Display errors in the minibuffer after a short delay.
(setq help-at-pt-display-when-idle t)
(setq help-at-pt-timer-delay 0.2)
Does not support double indentation levels for line-wrap which may generate spurious warnings.
For Developers >