Skip to content

Instantly share code, notes, and snippets.

@monzee
Created April 17, 2016 04:06
Show Gist options
  • Save monzee/d5d191deb1efbf184f7b83d33c6cb944 to your computer and use it in GitHub Desktop.
Save monzee/d5d191deb1efbf184f7b83d33c6cb944 to your computer and use it in GitHub Desktop.
A really simple makefile for single-file java programs. Put this in the same directory as the java file and run the program using `:!make main=%` in vim
path := $(dir $(main))
prefix := $(basename $(main))
class_name := $(notdir $(prefix))
COMPILE := javac
EXEC := java -cp .:$(path):$(cp)
.PHONY: run
run: $(prefix).class
$(EXEC) $(class_name)
%.class: %.java
$(COMPILE) $<
@monzee
Copy link
Author

monzee commented Apr 17, 2016

can also specify a classpath with cp=/path/to/lib:/path/to/more/libs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment