Maven Introduction

Maven is the most widely used build tool for Java. It manages your libraries, compiles code, runs tests, and packages everything into a JAR or WAR β€” all driven by a single file.

What Maven does for you

  • Dependency management β€” declare a library and Maven downloads it (and its dependencies).
  • Build β€” compile, test, and package with one command.
  • Standardization β€” every Maven project looks the same, so any developer can navigate it.
  • Plugins β€” extend the build (code coverage, Docker images, releases).

Convention over configuration

Maven expects a standard project layout, so you configure almost nothing if you follow it.

project
my-app/
β”œβ”€ src/main/java/       # your code
β”œβ”€ src/main/resources/  # config, static files
β”œβ”€ src/test/java/       # tests
β”œβ”€ target/              # build output (generated)
└─ pom.xml              # the project descriptor

Everything lives in pom.xml

The pom.xml (Project Object Model) declares your project's identity, dependencies, and build settings. It's the single source of truth Maven reads.

Maven vs Gradle

Maven uses declarative XML and rigid conventions β€” predictable and ubiquitous. Gradle uses a flexible Kotlin/Groovy script and is often faster. Both are common; this course covers Maven, which dominates enterprise Java.

Note: The current stable line is Maven 3.9.x. Maven 4 is arriving (release candidates), but 3.9 is what most projects use today. The Maven Wrapper (mvnw) pins the right version per project.
Free preview. Sign in and subscribe to unlock all 809 lessons across 25 courses.
Maven Introduction β€” Maven | Full Stack Learning Simplified