15
votes

There's plenty of closely related questions on SO, just to name some of them:

The difference of my questions is that I want to know how to make working with Java as easy as with Clojure right from Emacs within mixed Clojure/Java Leiningen project.

What I mean is possibility to (in order of priority):

  • compile Java code right from Emacs (note: it is possible to compile it from the shell with lein javac)
  • use code completion for Java (tools like JDEE provide this feature, but it is separate tool that doesn't concern Leiningen project setup)
  • debug Java code
4
JDEE is your best option if you really want to do the Java work in Emacs. IMO not worth it, but it's adequate.Dave Newton
For intellient completion you can try eclim which also has an emacs interface.Tom

4 Answers

1
votes

Check out the Emacs LSP project. It provides support for Java.

0
votes

I want to try auto complete but I haven't gotten to it yet.

Given the way leiningen/Clojure work anyway, I'm not sure how easy you could make compilation. When you compile Java code, don't you have to restart the repl/application for the JVM to reload it anyway?

0
votes

Malabar-mode is abandonware but I think it's shooting for the level of functionality that you want. It seems to me that a coprocess-based autocompletion engine should be feasible with CEDET, leiningen, and swank-clojure, but I have a day job and side work...

0
votes

Probably not what you wanted exactly, but this should handle bullet 1 for ya:

(defun lein-javac (&optional PROJECT-DIR)
  (interactive)
  (let ((output-buffer (progn
                         (with-output-to-temp-buffer "*lein-javac*" nil )
                         (select-window (get-buffer-window "*lein-javac*"))
                         (read-only-mode 'toggle)
                         (window-buffer)) ))
   (shell-command (concat "cd " (or PROJECT-DIR default-directory) 
                         " && lein javac &") "*lein-javac*")))