Working with Java from Emacs within Leiningen project
Asked Answered
P

4

15

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
Pollerd answered 19/2, 2012 at 14:38 Comment(2)
JDEE is your best option if you really want to do the Java work in Emacs. IMO not worth it, but it's adequate.Catlin
For intellient completion you can try eclim which also has an emacs interface.Traprock
D
1

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

Dremadremann answered 14/10, 2020 at 15:54 Comment(0)
C
0

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?

Compartmentalize answered 19/2, 2012 at 19:4 Comment(1)
Actually, it is possible to reload class from running Java process using custom ClassLoader (see example). However, I'm not switching between Java and Clojure too frequently, so it is ok for me to restart slime-clojure from time to time.Pollerd
I
0

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...

Impendent answered 28/3, 2012 at 2:13 Comment(0)
P
0

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*")))
Persia answered 22/4, 2019 at 0:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.