Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Core Tech
Labs

Guided: Automate Builds and Project Setup with Maven in Java SE

In this Code Lab, you'll build a command-line Java application using Maven to manage the project structure, dependencies, and build process. You will start by generating a project, then configure it, add code and tests, and finally package it into an executable JAR.

Lab platform
Lab Info
Level
Beginner
Last updated
Mar 13, 2026
Duration
45m

Contact sales

By clicking submit, you agree to our Privacy Policy and Terms of Use, and consent to receive marketing emails from Pluralsight.
Table of Contents
  1. Challenge

    Getting Started with Maven

    Welcome to this Code Lab on automating Java builds with Maven! Maven is a powerful build automation tool that simplifies the process of compiling code, managing dependencies, and packaging applications. It uses a declarative approach through an XML file, pom.xml, and favors convention over configuration, meaning it provides sensible defaults for project layouts, allowing you to get started quickly.

    In this first step, you'll use a Maven Archetype to generate a complete project skeleton. info> This lab experience was developed by the Pluralsight team using Forge, an internally developed AI tool utilizing Gemini technology. All sections were verified by human experts for accuracy prior to publication. For issue reporting, please contact us.

  2. Challenge

    Configuring the Project Object Model (POM)

    The heart of a Maven project is the pom.xml file. It describes the project, manages dependencies, and configures plugins. In this step, you'll modify the POM to update the Java version and add the libraries your application needs. This ensures your build is reproducible and consistent across all environments.

    info> Note: This lab environment has no external network access. A local Maven repository has been pre-populated with all the necessary dependencies. When you add a dependency to your pom.xml, Maven will find it in the local repository instead of downloading it from the internet.

  3. Challenge

    Developing the Application

    With the project structure and dependencies in place, it's time to write the application code. You'll follow Maven's standard directory layout, placing your application source code in src/main/java and resource files like facts.json in src/main/resources. This convention makes projects easy to navigate for any developer familiar with Maven.

    In the tasks below, you will be required to create files in the tooling. If you get stuck, please refer to the following step-by-step process:

    How to Create a File
    1. In the Filetree, navigate to the folder where you would like to create your file.
    2. Next to the desired folder, click the kebab menu icon.
    3. Select New file.
    4. Enter the filename and click Create file.
  4. Challenge

    Testing the Application

    Maven has a dedicated lifecycle phase for running tests. By placing test code in src/test/java, you keep it separate from your application code. Maven's Surefire plugin will automatically find and execute these tests when you run the mvn test command. You'll now write a unit test for your FactService and run it using Maven.

  5. Challenge

    Packaging and Running

    The final stage is to package your application for distribution. Maven plugins extend its core functionality. You'll use the maven-assembly-plugin to create a single, executable JAR file that includes your application code and all its dependencies. This is often called a fat JAR and makes running your application as simple as a single java -jar command.

About the author

Pluralsight’s AI authoring technology is designed to accelerate the creation of hands-on, technical learning experiences. Serving as a first-pass content generator, it produces structured lab drafts aligned to learning objectives defined by Pluralsight’s Curriculum team. Each lab is then enhanced by our Content team, who configure the environments, refine instructions, and conduct rigorous technical and quality reviews. The result is a collaboration between artificial intelligence and human expertise, where AI supports scale and efficiency, and Pluralsight experts ensure accuracy, relevance, and instructional quality, helping learners build practical skills with confidence.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight