Emacs and java are not good friends, for most of java programmers, the best choice of programming tools are IDE, for example Eclipse or IntelliJ IDEA, I agree that IDE is very friendly for Java programming especially for the web development for java, Most of my time is spent on IDE as well, I am a Emacs+ user in Eclipse, the experience is similar. However, I think there are some time for me to use emacs rather than IDE.
When I just open Emacs to code rather than Eclipse
1. When I want to focus on the design of code and structure of my programe , IDE is too annoying when I want to just write some interface or designing code. IDE sometimes just pop up a lot of code suggest andmay lead me to another direction. 2. When I want to combine the frontend code and backend code together. I just want to use emacs. Emacs provide a good auto-complete function for html (Emmet), CSS and JS, I don’t think Eclipse is good enough to handle these together. I don’t like to switch between Emacs and Eclipse very often, that will make me lost. 3. When I want to learn something new in Java. Emacs will make me focus on these features and try to remember these new features by head.
Solution:
There are three options for java programming in Emacs. One is Malarbra, but I didn’t successfully make that run, and I think you have to use some limited version of maven to make that run according to the specification. Another choice is JDEE <http://jdee.sourceforge.net>, which is a little old but a new version is under development. I think that is a good choice but still need some time to be ready. The last choice is Emacs-eclim, which is actually a shell for eclipse server, actually we still use Eclipse but use Emacs as a proxy and I think that is the best choice so far. Another mode your should never forget is yassnippet, for java install the this mode yasnippet-java-mode
Some Benefit
- Almost everything for Eclipse, you could insert getter and setter, problem report, auto import, auto suggest, but everything is called by yourself. So you could focus on the structure and correct errors after you finish the design. Just check the mode’s function and their names tell itself.
- Better Keybind, because I am using evil mode in emacs, so that means I could use vi and emacs together to code with the help of Eclipse.
- Here is a example to show a problem report in my Java Spring Project (The import java.util.HashSet is never used).


Some Tips and pitfall
Don’t use eclimd, which is a eclipse server in Emacs. That would make your Emacs crash. Instead, using Eclimd in terminal, I tried that in Mac, everything is OK.
You may need to set the varialble of eclim-executable variable in emacs to taget the eclim if you install Eclipse and Eclim in other place.
Finally, install eclim
For reference, in my Emacs setting.
(require-package 'emacs-eclim)
;;; enable the eclim
(require 'eclim)
(global-eclim-mode)
;; regular auto-complete initialization
(require 'auto-complete-config)
(ac-config-default)
;; add the emacs-eclim source
(require 'ac-emacs-eclim-source)
(ac-emacs-eclim-config)
(setq eclim-executable "/Applications/Eclipse.app/Contents/Eclipse/eclim")
(provide 'init-eclim)
However, I have to mention IDE is still the best time effective solution to Java development.
Leave me a message