---
description: Describe about Maven CLI
---

# Maven CLI

**Command**

1. `mvn validate`= Validate the project is correct and all necessary information is available. This phase checks the project's POM file and ensures that all required configurations and dependencies are defined correctly
2. `mvn clean` = It is a Maven command that is used to remove the `target` directory from your project. The `target` directory is where Maven stores all the compiled classes, JAR files, WAR files, and other artifacts generated during the build process. Running `mvn clean` ensures that the next build starts from a clean slate.
3. `mvn test`= Test the compiled source code using a suitable unit testing framework.
4. `mvn compile` = Compile the source code of the project. It processes the resources and source code to generate the bytecode (i.e., the `.class` files from `.java` files). It does not package the code into a `JAR` or `WAR` file, nor does it run tests or other build phases.
5. `mvn package` = Take the compiled code and package it into its distributable format, such as a `JAR`. It runs all lifecycle phases up to `package`, including `compile` and `test` phases. It does not install the package into the local Maven repository.
6. `mvn install` = This command runs all the phases in the default lifecycle up to `install`. It is not only packages the code but also installs the package into the local Maven repository (`~/.m2/repository`), making it available for other projects on the same machine. The phases executed include `validate`, `compile`, `test`, `package`, and `install`.
