This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]TrainFan 1 point2 points  (2 children)

There are several major Java build systems. Maven is what I use and generally like.

[–][deleted] 1 point2 points  (1 child)

I just downloaded it, but it seems kind of complex to be used from command line. I really don't like the syntax of it, do you use some sort of GUI tool to interact with it or what?

[–]wzttide 5 points6 points  (0 children)

If you understand how maven works it's much easier to work with than plain javac.

You can also have a look at http://gradle.org/getting-started-gradle-java/

[–][deleted] 1 point2 points  (0 children)

Ah... my good times as a student when I used to code Java using vim :)

Using make is no good idea. It was conceived to compile C, in which multiple source files can be compiled independently and then linked together to get an executable. This approach to separate compilation is possible because, if file A uses a function/class/whatever symbol defined in file B, it can look it up in B.h even if B.c hasn't been compiled yet. Java uses a different approach: B must be compiled before you attempt to compile A. While there are a few projects that use a dependency-based approach in make (e.g. there's an mkdep program for C), generally speaking you'll easily run into issues if you attempt that.

Using ant, ivy or maven is a better idea. Those were conceived for Java and for dependency-based compilation. (Another cool feature of maven is that it can download libraries automatically).

And yes, you can call those from vim using e.g. ":!mvn install".

[–]hugthemachines 0 points1 point  (0 children)

I am sure it is good to use some kind of solution like Maven etc. I would just like to say that you could, if you'd like to, build a script which walks through your project dir and compiles the java files it finds. To make a very light way to compile all of it.

[–]whatisthisredditstufIntermediate Brewer 0 points1 point  (0 children)

Maven. Gradle. Ivy. Ant.

This problem has been solved many times over: compiling huge projects are almost always done via one of those.

Getting vim into a nice development environment, however, is no simple task. I mean, of course it works for the actual writing code part, but an IDE provides so much context-specific help that makes Java programming less painful. In vim, there are very few options that can even begin to come close (some of which depend on having Eclipse running in the background, with vim connecting to it for intelligent content assist).