Make: Build Automation Tool

What is Make?

Make is a build automation tool that helps compile and manage large projects by reading instructions from a file called a Makefile.

Why Use Make with Java?

How Make Works

  1. The user runs the make command.
  2. Make looks for a Makefile in the current directory.
  3. Make checks which Java files have changed and recompiles them if needed.

Example Makefile for Java

This example builds a Java program with two classes: Main.java and Utils.java.


# Makefile for Java
JAVAC = javac
JAVA_FILES = Main.java Utils.java

all: Main.class

Main.class: $(JAVA_FILES)
	$(JAVAC) $(JAVA_FILES)

clean:
	rm -f *.class
  

Logo

Makefile Dependency Diagram

Learn more about Make at the official GNU Make Documentation.