22

I'm making yet another attempt to convert over to Emacs. I'm a decent Vi user but have been using Eclipse for most of my development work for the past 10+ years (has it been that long).

So I did some reading up and thought that JDEE is the way to go -- have it configured but still have some basic questions.

But, after doing some more research -- it seems JDEE may not be well maintained and perhaps all I need is CEDET?

So question:

  1. Can Emacs serve as my Eclipse replacement? I organize my build using Maven?
  2. If "1" is yes that what suite of tools should I start with: CEDET? JDEE?

Thanks.

  • 4
    Emacs is a great editor, but not a great Java IDE. You will be dissappointed. – Thorbjørn Ravn Andersen Jun 22 '15 at 9:35
20

I'm going to be conservative and say no, Emacs is not a drop-in replacement for Eclipse (especially not out of the box). However, that doesn't mean that it's not suitable for Java development.

Since you are already familiar with Eclipse I suggest you have a look at eclim:

Eclim provides the ability to access Eclipse code editing features (code completion, searching, code validation, and many more) via the command line or a local network connection, allowing those features to be integrated with your favorite editor.

Eclim supports Maven. It integrates with Emacs via a package called emacs-eclim. Follow the steps outlined in the emacs-eclim README to install it1:

  1. Download and install eclim.

  2. Install emacs-eclim:

    • If you haven't already, add MELPA to package-archives:

      (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)

    • Evaluate the code above (by pressing C-x C-e with point positioned after the last closing paren) or restart Emacs.

    • Install emacs-eclim by doing M-x package-install RET emacs-eclim RET.
  3. Add the following code to your init-file:

(require 'eclim)
(global-eclim-mode)

1Instructions modified to include only a single installation method.

  • 1
    may many thanks for the answer - I am familiar with eclim, however I'm trying to get away from eclipse due to it's bloat - though I do appreciate that this is a good transition step. – user1172468 Jun 22 '15 at 8:29
  • 1
    So question: say if eclim didn't exist, what would be your recommendation? – user1172468 Jun 22 '15 at 8:29
  • Learn to live without refactoring then. – wasamasa Jun 22 '15 at 8:41
  • 2
    @user1172468 It depends -- What types of features do you want? A full-blown replacement for Eclipse will inevitably contain some bloat. If you want to get away from that your best bet is to come up with a list of specific use cases and check if (a) Emacs supports them out of the box and/or (b) there is an add-on package that provides relevant functionality. We can help you with that, but only if you let us in on your must-have features :) – itsjeyd Jun 22 '15 at 9:02
  • 1
    It should be noted that with Eclim you can run Eclipse without the GUI stuff, which will use less resources. Another thing about Eclim is that its autocompletion isn't usable (it has to save the buffer before requesting completion + it locks the editor while waiting for response). – wvxvw Jun 22 '15 at 9:41
11

Emacs/eclim has been my primary Java IDE for the last couple of years and would say it works fairy well, even with large code bases (my current emacs/eclim workspace has more than 4000 Java files). It's true that emacs-eclim requires the file to be saved before making its call to eclimd, but it's not that big of a problem IMO. The editing experience is still good and the debugger (using gud) is ok.

If you resent all solutions based on Eclipse, I would recommend Malabar mode. I've used that for a couple of years too (before I switched to emacs-eclim) and it has some nice features, top of which is that it works out of the box with any Maven project. If you use Maven, malabar-mode will instantly give you auto completion and code navigation (among other things). With malabar, I used jdibug for debugging remote Java processes.

The oldest Java package for Emacs, JDEE, might also be worth checking out. Here, you'll find lots of IDE features implemented in pure elisp (or accompanying Java programs launched via bsh), but last time I used it, it was pretty dated. I may be mistaken, but last time I checked, JDEE was best suited for Java <= 1.4 and the debugger that worked the best with it was jdb (the others were too slow).

Lastly, regardless of which Java package you choose, I'd also throw in Projectile for lots of project related goodness.

8

At this point(2018), LSP Java(https://github.com/emacs-lsp/lsp-java) is pretty good. Few of the features:

  1. Autocomplete
  2. Refactoring (extract method, rename, implement interface, extract local, extract constant and so on.)
  3. Auto import
  4. Code navigation while working on multiple projects
  5. Find references, implementations, open type.
  6. Maven/Gradle project import, automatic build, automatic project configuration update
  7. Easy to setup
  8. Formatter preference
  9. Flycheck support + quick fixes like "Add cast", "Surround with try/catch", etc.

The major selling point is that there are fulltime developers working on the LSP Java backend https://github.com/eclipse/eclipse.jdt.ls which brings up new features almost every week.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.