Clojure+Java Emacs setup

Studying dtype-next, I am realizing that for some time I haven’t had a full Java dev environment.

In the past, I used to uncomfortably shift between Eclipse/IntelliJ to a very partial dev experience at Emacs through emacs-eclim and such. Nowadays, I hear the situation might be better, thanks to the Language Server Protocol.


Still, I wonder how that may play well with a Leiningen project that contains both Clojure and Java.

Does anybody here have a recommended Emacs (preferably Spacemacs) setup for Clojure+Java development?

I did a lot of combined Java + Clojure work until a year ago, and switching between IntelliJ and Emacs was the best setup back then (also, this was a maven-based codebase)… I’ve had moderate success in setting up LSP-mode and DAP under doom emacs, but I haven’t really put much effort into it (luckily, not doing any Java these days)

1 Like

Many thanks, @mvarela. It helps a lot to know.

Hi @daslu,
Were you able to get it working in a Leiningen polyglot project ? Recently I tried the same in a couple of projects using spacemacs. My settings are essentially @practicalli’s setup for spacemacs + java lsp and I have to generate and manually configure the pom.xml for each project in order for the java-lsp to work correctly - specifying java target version and such.

While the setup mostly works fine, but I encounter some annoying problems from time to time - though it may be due to my lack of knowledge and wrong configs. The most annoying of them is that sometimes upon switching to a java file, the lsp does not recognize the dependencies at all and keep complaining about them. When this happens I have to clean the project and restart spacemacs for it to work.

I’d be glad if you could share your experience as well.

Hi @clov0!

I must admit I have not tried it yet, but rather used a friend’s advice, not to develop Clojure and Java at the same project.

Hearing about your experience makes me more optimistic.

I have always kept Clojure and Java development projects separate and advise that this is the simplest approach. Then simply add the java library as a dependency to the Clojure project.

Emacs and Java with LSP seems to be very comprehensive (more so than Clojure & LSP, although that does keep improving)

There is a very interesting demo video showing Emacs and Java development

Again, I’d avoid polyglot projects as they are often a source of many small issues during development, testing, CI and deployment tasks.

1 Like

I alternate between IntelliJ for Java and Emacs for Clojure. Sometimes I’ll do some Java in Emacs, and Java LSP has improved a lot, but I still often have issues with it, so when I’m going to be doing a lot of Java and Clojure together I have both editors opened.