In a terminal (*uix or Mac) or command prompt (Windows), navigate to the folder you want to create the Java project. Type this command :
This tells Maven to generate a Java project from a Maven template. For example,
Above command will generate a Java project from maven-archetype-quickstart template.
The following project directory structure will be created. In short, source code puts in folder /src/main/java/, unit test code puts in
Review the generated
pom.xml. It’s quite empty, just a single
This POM file is like the Ant
build.xml file, it describes the entire project information, everything from directory structure, project plugins, project dependencies, how to build this project and etc, read this official POM guide.
6.1 Let build it with
It compiles, run unit test and package the project into a
jar file and puts it into the
7.1 Run it. Oops… By default, Maven didn’t add the project dependencies
commons-codec into the jar file.#
7.2 To solve it, we can use this
maven-shade-plugin to create an uber/fat-jar – group everything into a single jar file.#
Two jars will be generated, review the file size :
Final POM file.