2

I'm new to the java world. For the past year I've been doing C#/C/C++ development in vim in linux, and have really grown to love it. Dotnet-cli was great to use, and, although there was no C# debugger in linux until one was built into vscode recently, coding and running in eclipse was fairly easy.

The questions I've seen asking SO how to do java development in vim/emacs have all refused to address answering the question and instead focus on trying to convince the person to give up and use an IDE. Well for reasons passing understanding, that's simply not an option. Some test work in intelliJ, some in eclipse, and some I need to drop down to the command line.

I'm wondering, I've heard of jdb as a command-line debugger. We are using maven as a build tool. Despite clear documentation, I've yet to see how to get an individual test to run in maven using -Dtest=TestClassName#testActualTestCase. It would seem that's really the only thing holding me up. Using jdb would be extremely nice as well. Does anyone know how to use jdb with maven in the command line? Another nice-to-have would be code-completion for java in either emacs or vim (I'm really not picky... I'll use both as they're both great, but I prefer vim for day-to-day editing as it's SOOOO lightweight).

EDIT: no... I don't want to use Eclim. I specifically need only to run tests, code, and edit text. Nothing fancy.

Zach Folwick
  • 893
  • 10
  • 18
  • I can't provide any support with respect to your question, but, if some things work in IntelliJ, and others work in Eclipse, and neither is working correctly, it sounds to me like there are problems that need addressing, and those should probably be addressed before looking into setting up some command-line IDE-like. What if a new guy joins your project, and he wants to use a normal IDE (definitely not an unreasonable request)? Also, I don't know how the IDE manages to affect tests passing/failing. That shouldn't be happening. Anyway, those are my thoughts. Good luck. – Ironcache May 20 '16 at 18:56
  • @Ironcache - I *am* the new guy. I just spent 3 days debugging what ended up being essentially "eclipse sucks. Use IntelliJ. Sometimes Eclipse gets confused when the POM is dirty/has duplicate references/gremlins/..." I agree wholeheartedly with you- stuff needs to be addressed, however I'm done with editor wars. Is the stance of the java community SERIOUSLY that it *cannot* work without an IDE? This seems like a trivial request... – Zach Folwick May 20 '16 at 19:08
  • 1
    My point wasn't that it "*cannot* work without an IDE", as much as it was that it should work irrespective of the IDE. If someone wants to develop purely through vim/emacs, it should work. If someone wants to develop purely through Eclipse, it should work. I think your pursuit is valid if you feel like you develop better in that environment. I'm just saying that the fact that things **aren't** working in specific IDEs just raises red flags to me. – Ironcache May 20 '16 at 19:21
  • Though, trying to help with the actual issue, what fails when you try to run individual maven tests? – Ironcache May 20 '16 at 19:29
  • Um this is not unreasonable. does vim -D not work? – Tim Lieberman Sep 21 '18 at 18:18

2 Answers2

1

It has been years since I used vim for development, so I will focus on the Emacs part.

Currently there are four options for Java development in Emacs: meghanada, jdee, ensime, eclim. I had at least played with everyone of them. Sadly all have certain quirks and I cannot really recommend any of them for serious Java development.

However if you do want to try with Emacs. I feel Meghanada would give the best shot. It is not mature enough, but already supports auto-completion, syntax-checking and runs junit tests. It will also parse maven and gradle projects automatically. The overall experience is smooth enough for small and moderate scale projects. Refactoring support is still in its todo list though.

Jdee is solid but a bit obsolete. It does not understand some modern features of java (annotation for example). The completion interface is clunky. And people claim it to be difficult to install.

Ensime is my choice for Scala development. It has limited support for java but does not seem to play well with maven or gradle.

As for debugging, realgud has experimental support for jdb and meghanada has a feature to connect to it. Although I never got it working.

Jun Zhang
  • 198
  • 1
  • 7
0

You should take a look at eclim. It allows you to connect to eclipse through vim and use it for building, debugging, and code completion. It can also run junit tests. It's possible to run an individual test by placing your cursor somewhere in a test method and running a vim command. I've never used it in conjunction with maven or jdb, but the eclim documentation or google group might be able to help if you decide to go this route.

  • "The questions I've seen asking SO how to do java development in vim/emacs have all refused to address answering the question and instead focus on trying to convince the person to give up and use an IDE." – Zach Folwick May 20 '16 at 19:10
  • He is providing a way to "do java development in vim/emacs". This is an answer to the question. The fact that it piggybacks off of Eclipse is definitely a compromise, and maybe not suitable to your needs, but I don't think he should be downvoted for attempting to help... – Ironcache May 20 '16 at 19:16
  • There are other alternatives that I've tried for maintaining a Java project in Vim, like complicated setups with Syntastic, Ant, and various auto complete plugins. This got complicated really quick because of how many moving parts you have to keep up with manually. Using Eclim for code completion, and style checking was a good compromise for me (I still use ant for building and running). It's possible to do what you want without eclim, but the set up you will come up with is highly dependent on how the project you are working on is setup. –  May 20 '16 at 19:32
  • @ZachFolwick ironcache danny when you have to debug off your box because of constraints eclipse isn't going to do you any good. It would be great if everyone could just push a button but that's amateur hour. – Tim Lieberman Sep 23 '18 at 04:36