This is a small sample project that seeks to provide a template or starter kit for java projects on *nix.
With that in mind, it provides a ready-to-go Makefile, along with a complete (dummy) java program as proof of concept that it works. The Makefile is commented and should prove fairly straightforward; I recommend reading the docs if there are questions.
Also check the .gitignore for some suggestions.
Using the Makefile requires editing just a few key lines, all of which are variable definitions:
JAR_FILEcontrols the name of the produced jarMAINshould be the path undersrcto a java file with themainmethodTESTshould be the path undersrcto a java file with amainmethod that invokes whatever test setup you have
Other variables can be changed in the Makefile or even set as environment variables, but should "just work" by default.
It assumes the following project structure
srccontains.javasource fileslibcontains.jarfiles (libraries) on which the source dependsbinwill contain generated.classfiles (and is automatically generated)scriptswill contain generated files that can be executed to run the program as if it were a regular CLI binary, passing along all arguments
all: the default. Builds the class filesjar: make the 'jarchive'runners: make the scriptstest: run the testsclean: delete any generated filesjdb: run the debugger (jdb)
I've got a script to download the newest version of the Makefile here;
it will even save and restore your changes to JAR_FILE and MAIN. If you
change lots of things, though, I wouldn't recommend using it. This is a place
where it's good to have things in version control.
Vim User?
See my Dotfiles for some examples of ways I make coding Java in Vim
easier. Of particular relevance is my javamake compiler plugin.