Complete Computing Environment: Java Programming in Emacs

Table of Contents

(provide 'cce-java)

Eclim, the brain of the integration

Java development is generally done in an IDE, mostly because of the verbose design patterns requiring a really good autocomplete system, jump-to-definition, auto-building, inline debugging, and other fairly heavy systems that are tightly integrated in to the Java ecosystem.

The hack here, famously done for Vim users wanting to use a full Vim experience for Java development, is Eclim1, a plugin for Eclipse to expose Eclipse's view of a project and a daemon that runs a headless Eclipse with that plugin enabled.

I tried to get it to work with Fedora's Eclipse but of course was getting some opaque error message about something going wrong, so I opt to just install Eclipse to /opt

pushd /tmp
wget http://mirror.cc.columbia.edu/pub/software/eclipse/technology/epp/downloads/release/neon/3/eclipse-java-neon-3-linux-gtk-x86_64.tar.gz
tar -xvf eclipse-java-neon-3-linux-gtk-x86_64.tar.gz
sudo mv eclipse /opt
sudo chown -R rrix.rrix /opt/eclipse

wget https://github.com/ervandew/eclim/releases/download/2.6.0/eclim_2.6.0.jar
java -jar -Dvim.skip=true -Declipse.home=/opt/eclipse/ eclim_2.6.0.jar install
popd
(install-pkgs '(eclim))

(add-hook 'java-mode-hook (lambda ()
                            (require 'eclim)
                            (eclim-mode)))

(setq eclimd-executable "/opt/eclipse/plugins/org.eclim_2.6.0/bin/eclimd"
      eclim-executable "/opt/eclipse/plugins/org.eclim_2.6.0/bin/eclim")

Emacs-side Integration, Java-mode

(defun cce/java-test ()
  (interactive)
  (eclim-maven-run "test"))

(define-key java-mode-map (kbd "C-c C-c") #'cce/java-test)

Footnotes:

Author: Ryan Rix

Created: 2017-07-02 Sun 11:26

Validate XHTML 1.0