Skip to content

Maven and Your First Test


For this lab, you'll need Maven installed, so follow the instructions here.

Don't install IntelliJ yet, just Maven.

Step 1: Create New Project

Create a new directory for your project and switch to make that the current directory, e.g.:

> mkdir app
> cd app

Use Maven to initialize a new project by running the following command at the command line:

So if you're in the


Directory, copy-n-paste this command:

 mvn archetype:generate -DartifactId=cvm -DarchetypeGroupId=com.thepracticaldeveloper -DarchetypeArtifactId=archetype-java-basic-tpd -DarchetypeVersion=1.0.0 -DinteractiveMode=false

You will then see a lot of output, ending (hopefully) with:

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  19.134 s

Change directory to the generated project:

C:\app> cd cvm

If you do a directory listing, you'll see something like

C:\app\cvm> dir


Step 2: Build the App via Maven

Maven has a number of "goals", such as "compile", "validate", etc.

Package up the app using mvn clean package

> mvn clean package

Step 3: Running the App

> java -cp target/cvm-1.0.0-SNAPSHOT.jar

Once you've completed the above steps, check in with the instructor to review your code.