Skip to content

Latest commit

 

History

History
121 lines (96 loc) · 4.96 KB

ome-java.org

File metadata and controls

121 lines (96 loc) · 4.96 KB

Oh My Emacs Java

This is part of oh-my-emacs.

Prerequisites

PackageWindowsUbuntu/Debian/MintArchLinuxFedoraMac OS XMandatory?
eclipseYes

El-get packages

PackageStatusDescription
emacs-eclimRequiredThe bridge between emacs and eclipse.

Eclim

Emacs was a really great idea in the seventies and one of the frightening things about Emacs today is if you skip the last 20 years it is much the same.

Don’t use Emacs, says Java’s father

I must say that it is really a pain to do Java programming with Emacs, however, when I turn to a modern IDE(eclipse/netbeans), just as Java’s father said, I would miss Emacs again. You want to know why? Refer to Why I Still Use Emacs.

However, Eclipse, or some other java IDEs, do provide some fascinating features such as refactoring, 100% absolutely correct semantic completion, on-the-fly syntax checking, maven/ant integration, etc.

Fortunately, there comes emacs-eclim, which brings the power of Eclipse to Emacs by utilizing eclim, ah, the best of both world.

To install eclim, first you need to install Eclipse. You can install Eclipse through your OS package manager, or you can download a tarball directly from official eclipse website. I recommend the later method since it is much more portable, and dumps all eclipse files to a single folder, say, /opt/eclipse/ for example. And one extra advice, I recommend you install Eclipse version 3.x instead of 4.x since 4.x is not stable enough IMHO. My working environments include Eclipse 3.7 and eclim_1.7.18. I didn’t have too much time to test other combinations, so if you encounter problems, don’t hesitate to open a new issue in oh-my-emacs’s github.

Then you should download and install eclim, see eclim install guide for details. I use the following command to do an automated install.

java -Dvim.files=$HOME/.vim -Declipse.home=/opt/eclipse -jar eclim_1.7.18.jar install

Oh-my-emacs assumes that you install Eclipse to /opt/eclipse/ directory, and set your Eclipse workspace to $HOME/workspace. So if your settings are different, don’t forget to set eclim-executable and eclimd-executable properly. Finally, ensure that you can find eclipse in your shell’s $PATH since oh-my-emacs relies on this way to determine the availability of Eclipse.

Ok, that’s enough, you want to know what eclim can provide for you? Enterprise Java Development in Emacs show you an illustrated guide.

(defun ome-eclim-setup ()
  ;; (add-to-list 'eclim-eclipse-dirs "/opt/eclipse")
  (setq eclim-auto-save t
        eclim-executable (or (executable-find "eclim") "/opt/eclipse/eclim")
        eclimd-executable (or (executable-find "eclimd") "/opt/eclipse/eclimd")
        eclimd-wait-for-process nil
        eclimd-default-workspace "~/workspace/"
        help-at-pt-display-when-idle t
        help-at-pt-timer-delay 0.1)

  ;; Call the help framework with the settings above & activate
  ;; eclim-mode
  (help-at-pt-set-timer)

  ;; keep consistent which other auto-complete backend.
  (custom-set-faces
   '(ac-emacs-eclim-candidate-face ((t (:inherit ac-candidate-face))))
   '(ac-emacs-eclim-selection-face ((t (:inherit ac-selection-face)))))

  ;; Hook eclim up with auto complete mode
  (require 'ac-emacs-eclim-source)
  ;; (ac-emacs-eclim-config)

  (require 'eclimd)

  (add-hook 'java-mode-hook
            (lambda ()
              (add-to-list 'ac-sources 'ac-source-emacs-eclim)
              (eclim-mode t))))

(when (executable-find "eclipse")
  (ome-install 'eclim))

Todo

  • Complitation support, use M-n and M-p to navigate the eclim warnings and errors just like c-mode and c++-mode.
  • Provide a menubar to eclim thus users can get a quick overview of eclim features.
  • Eclim would report warnings like describe-mode: Symbol's function definition is void: eclim-project-mode when you hit C-h m in auxiliary eclim modes.