Skip to main content

Programming languages · Beginner · 24 min

Build and test a Java project with Maven

By Padding · Updated 18 Nov 2026
Ubuntu 26.04 · Eclipse Temurin JDK 25.0.5 · Maven 3.10.2

You will install Maven 3.10, create a small bill-splitting app from the quickstart archetype, test it with JUnit 6, trace a dependency with dependency:tree, package it as a runnable JAR and prove that ./mvnw verify passes on a fresh checkout.

On this page

Maven is a build tool for Java. You describe your project in one file, pom.xml: its name, the Java version it targets, the libraries it needs. Maven then downloads those libraries, compiles your code, runs your tests and packages the result, the same way on every machine. Most Java back ends you will meet at work, and many test automation suites, are built this way.

In this tutorial you build a small command-line app that splits a bill fairly between friends, down to the last kobo or cent. Along the way you read every part of a pom.xml, write JUnit 6 tests, walk through Maven's lifecycle phases, find out where a library came from, and make a JAR anyone with Java 25 can run. The last step clones the project as a teammate would and proves the build works there with nothing but Java installed.

You will use Maven 3.10.2, the current release. Maven 4 is close but still a release candidate, so stay on 3.10 for real projects for now. Version 3.10 is stricter than 3.9 in one way that matters to you: it no longer fixes the versions of the core plugins for you, so every project should pin them. The pom.xml in this tutorial does.

Step 1 · Install Maven 3.10 and check its checksum

Ubuntu's own maven package can lag behind, so install the release from Apache directly. Download the archive and its SHA-512 checksum from Maven Central, where Apache publishes every Maven release, and make sure the two match before you unpack anything:

Bash
sudo apt update
sudo apt install -y curl
cd /tmp
curl -fsSLO https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.2/apache-maven-3.10.2-bin.tar.gz
curl -fsSLO https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.2/apache-maven-3.10.2-bin.tar.gz.sha512
echo "$(cat apache-maven-3.10.2-bin.tar.gz.sha512)  apache-maven-3.10.2-bin.tar.gz" | sha512sum -c -

The .sha512 file holds only the hash, so the echo adds the file name in the format sha512sum -c expects. If it prints anything other than OK, delete the download and try again; do not install a file that fails the check.

Unpack Maven into /opt, point a stable /opt/maven link at it and put mvn on your PATH:

Bash
sudo tar -xzf apache-maven-3.10.2-bin.tar.gz -C /opt
sudo ln -sfn /opt/apache-maven-3.10.2 /opt/maven
sudo ln -sf /opt/maven/bin/mvn /usr/local/bin/mvn
rm apache-maven-3.10.2-bin.tar.gz apache-maven-3.10.2-bin.tar.gz.sha512
mvn -version

A hand-installed Maven gets no updates from apt. To upgrade later, repeat these two blocks with the new version number in place of 3.10.2. The ln -sfn line moves /opt/maven to the new folder, and you can then delete the old one from /opt.

Check it worked

The first block ends with apache-maven-3.10.2-bin.tar.gz: OK. mvn -version starts with Apache Maven 3.10.2, then shows Maven home: /opt/apache-maven-3.10.2 and a Java version: 25.0.5 line, or a later 25 patch. If the Java line names an older version, Maven found a different JDK first on your PATH.

Step 2 · Create a project from the quickstart archetype

An archetype is a project template. The quickstart archetype gives you the standard Maven folder layout with one class and one test. Make a throwaway folder and generate the project in it. Every option is on the command line, and -B (batch mode) stops Maven from asking questions:

Bash
mkdir -p ~/maven-demo
cd ~/maven-demo
mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.4.1:generate \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DarchetypeArtifactId=maven-archetype-quickstart \
  -DarchetypeVersion=1.5 \
  -DgroupId=com.example \
  -DartifactId=bill-splitter \
  -Dversion=1.0-SNAPSHOT \
  -Dpackage=com.example.split \
  -DjavaCompilerVersion=25
cd bill-splitter
find . -type f | sort

The long first argument names the plugin by its full coordinates and version, maven-archetype-plugin 3.4.1, and the goal to run, generate. Naming the version keeps the result the same next year. The first run downloads a lot: Maven fetches each plugin and library once and keeps it in ~/.m2/repository. On prepaid mobile data, run your first build on Wi-Fi if you can. After that, builds reuse the local copies, and mvn -o (offline) works with no connection at all once everything is cached.

Check it worked

Maven ends with BUILD SUCCESS, and find lists something like this:

Text
./.mvn/jvm.config
./.mvn/maven.config
./pom.xml
./src/main/java/com/example/split/App.java
./src/test/java/com/example/split/AppTest.java

Code lives under src/main/java, tests under src/test/java, and the folders below that follow the package name. The two empty files in .mvn are where a project can keep JVM options and default Maven flags.

Step 3 · Read the pom.xml

Open pom.xml in your editor. The archetype wrote it, and every Maven project has the same main parts:

  • Coordinates. groupId (com.example), artifactId (bill-splitter) and version (1.0-SNAPSHOT) together name this project uniquely, the same way you will name the libraries you use. A version ending in -SNAPSHOT means "work in progress": it can change. A version without it, such as 1.0, is a release and should never change once published.
  • Properties. project.build.sourceEncoding makes Maven read source files as UTF-8 on every machine, so names such as Adéolá survive a build on Windows. maven.compiler.release set to 25 tells the compiler to produce Java 25 bytecode and to allow only the Java 25 standard library.
  • Dependency management and dependencies. The archetype imports the JUnit 5.11 BOM (bill of materials), a list of matching versions for all the JUnit pieces, and then declares junit-jupiter-api without repeating a version. Each dependency has a scope. test means it is on the classpath only when compiling and running tests, never in the app you ship. With no scope, a dependency is compile: needed by your code and by anyone who runs it.
  • Plugin management. Maven does the real work through plugins: the compiler plugin compiles, Surefire runs tests, the jar plugin packages. The <pluginManagement> block pins each plugin's version. Without it, Maven 3.10 falls back to default versions and warns you; builds should not depend on what the Maven you happen to run picks.

The archetype pins JUnit 5 and plugin versions from 2024. Replace the whole file with an up-to-date version. It moves to JUnit 6.1.3, adds one library you will use, Apache Commons Text, and pins current plugins:

Bash
cat > pom.xml <<'XML'
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>bill-splitter</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>bill-splitter</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.release>25</maven.compiler.release>
    <junit.version>6.1.3</junit.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-text</artifactId>
      <version>1.15.0</version>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.5.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.5.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.16.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.6.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.5.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.11.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-wrapper-plugin</artifactId>
          <version>3.3.4</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>
XML
mvn validate

junit-jupiter is JUnit's all-in-one artifact: the API you write tests against, parameterised tests, and the engine Surefire uses to run them. Its version comes from the BOM, so moving to a later JUnit means changing the one junit.version property. Plugins without a groupId default to org.apache.maven.plugins.

Check it worked

mvn validate checks that the POM is well formed and complete, without compiling anything, and ends with BUILD SUCCESS. Maven 3.10 fails here, not later, on mistakes such as the same dependency listed twice. Try it: paste the commons-text block a second time, run mvn validate, read the error, then remove the copy.

Step 4 · Write the code and its JUnit 6 tests

The app takes a total in minor units (kobo, cents, pesewas) and a list of names, and says who pays what. Working in whole minor units avoids the rounding errors of double. When the total does not divide evenly, the first people pay one unit more, so the shares always add up to the total.

Write the splitting logic as its own class, so it can be tested without the command line:

Bash
cat > src/main/java/com/example/split/BillSplitter.java <<'JAVA'
package com.example.split;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public final class BillSplitter {
    private BillSplitter() {
    }

    public static List<Long> split(long totalMinorUnits, int people) {
        if (people < 1) {
            throw new IllegalArgumentException("people must be at least 1");
        }
        if (totalMinorUnits < 0) {
            throw new IllegalArgumentException("total cannot be negative");
        }
        long base = totalMinorUnits / people;
        long remainder = totalMinorUnits % people;
        List<Long> shares = new ArrayList<>(people);
        for (int i = 0; i < people; i++) {
            shares.add(i < remainder ? base + 1 : base);
        }
        return shares;
    }

    public static String format(long minorUnits) {
        return String.format(Locale.ROOT, "%d.%02d", minorUnits / 100, minorUnits % 100);
    }
}
JAVA

Locale.ROOT matters more than it looks. Without it, String.format follows the computer's language settings, and on a machine set to Arabic or Persian the digits themselves can change. Output meant for other programs should not depend on who runs it.

Now replace the generated App.java with the command-line entry point. It uses WordUtils from Commons Text to tidy the names, so ada prints as Ada:

Bash
cat > src/main/java/com/example/split/App.java <<'JAVA'
package com.example.split;

import java.util.List;
import org.apache.commons.text.WordUtils;

public class App {
    public static void main(String[] args) {
        if (args.length < 2) {
            System.err.println("usage: bill-splitter <total-in-minor-units> <name>...");
            System.exit(2);
        }
        long total = Long.parseLong(args[0]);
        int people = args.length - 1;
        List<Long> shares = BillSplitter.split(total, people);
        for (int i = 0; i < people; i++) {
            String name = WordUtils.capitalizeFully(args[i + 1]);
            System.out.println(name + " pays " + BillSplitter.format(shares.get(i)));
        }
    }
}
JAVA

Delete the archetype's placeholder test, which only asserts true, and write real tests. Surefire runs every class under src/test/java whose name ends in Test:

Bash
rm src/test/java/com/example/split/AppTest.java
cat > src/test/java/com/example/split/BillSplitterTest.java <<'JAVA'
package com.example.split;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

class BillSplitterTest {

    @Test
    void sharesAddUpToTheTotal() {
        List<Long> shares = BillSplitter.split(10_000, 3);
        assertEquals(List.of(3334L, 3333L, 3333L), shares);
        assertEquals(10_000L, shares.stream().mapToLong(Long::longValue).sum());
    }

    @Test
    void rejectsZeroPeople() {
        IllegalArgumentException error =
                assertThrows(IllegalArgumentException.class, () -> BillSplitter.split(500, 0));
        assertEquals("people must be at least 1", error.getMessage());
    }

    @ParameterizedTest
    @CsvSource({"0, 0.00", "5, 0.05", "3334, 33.34", "150000, 1500.00"})
    void formatsMinorUnits(long minorUnits, String expected) {
        assertEquals(expected, BillSplitter.format(minorUnits));
    }
}
JAVA
mvn test

@Test marks a test method. assertThrows checks that the code fails the way you meant it to, and hands you the exception to inspect. @ParameterizedTest with @CsvSource runs one method once per row, so four formatting cases cost four lines. Test classes and methods in JUnit 6 do not need to be public.

Check it worked

Near the end of the output, Surefire prints Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, two plain tests plus four rows of the parameterised one, then BUILD SUCCESS. The same summary is saved in target/surefire-reports/, where CI servers read it. To run a single test while you work on it, use mvn test -Dtest=BillSplitterTest#rejectsZeroPeople.

Step 5 · Walk through the lifecycle phases

You never told Maven to compile before testing. test is a phase in Maven's default lifecycle, an ordered list, and asking for one phase runs every phase before it. The ones you use most are:

  1. validate: the POM is correct and complete.
  2. compile: compile src/main/java into target/classes.
  3. test: compile the tests and run them with Surefire.
  4. package: bundle the compiled code, here as a JAR in target/.
  5. verify: run checks on the package, such as integration tests, when plugins are bound to it.
  6. install: copy the package into your local repository, ~/.m2/repository, so other projects on this computer can depend on it.

After install comes deploy, which uploads to a shared repository for your team; it needs a server and is not used here. clean belongs to a separate lifecycle: it deletes target/ so the next build starts from nothing. Run the phases one at a time and look at what each leaves behind:

Bash
mvn clean compile
ls target/classes/com/example/split
mvn package
ls target/*.jar
mvn install
ls ~/.m2/repository/com/example/bill-splitter/1.0-SNAPSHOT/

mvn clean compile runs clean first, then every default phase up to compile. mvn package runs the tests again on its way to the JAR: a failing test stops the build before anything is packaged. You can skip tests with -DskipTests, but a JAR built that way has not been checked, so keep the flag for emergencies.

Check it worked

target/classes/com/example/split holds App.class and BillSplitter.class, with no test classes. ls target/*.jar shows target/bill-splitter-1.0-SNAPSHOT.jar. After install, the local repository folder holds bill-splitter-1.0-SNAPSHOT.jar and bill-splitter-1.0-SNAPSHOT.pom, the same layout Maven uses for every library it downloads.

Step 6 · Find where a library came from with dependency:tree

You declared two dependencies, but your build uses more. Each library brings its own dependencies, called transitive dependencies. When a strange JAR appears, or two versions of one library clash, dependency:tree shows who pulled what in:

Bash
mvn dependency:tree

The output is something like this (the JUnit lines are trimmed):

Text
com.example:bill-splitter:jar:1.0-SNAPSHOT
+- org.apache.commons:commons-text:jar:1.15.0:compile
|  \- org.apache.commons:commons-lang3:jar:3.20.0:compile
\- org.junit.jupiter:junit-jupiter:jar:6.1.3:test
   +- org.junit.jupiter:junit-jupiter-api:jar:6.1.3:test
   ...

Each line ends with the scope. commons-lang3 sits under commons-text: you never asked for it, but Commons Text needs it, so it ships with your app. Everything under JUnit has test scope and stays out of your app. On a big project the tree runs to hundreds of lines, so filter it to the one library you are asking about:

Bash
mvn dependency:tree -Dincludes=org.apache.commons:commons-lang3

If two paths ask for different versions of the same library, Maven picks the one nearest the top of the tree. Declaring the library yourself in <dependencies> puts it at the top, so your version wins.

Check it worked

The filtered tree shows only the path to commons-lang3: your project, then commons-text:jar:1.15.0, then commons-lang3:jar:3.20.0:compile. Try -Dincludes=org.junit.platform to see which JUnit pieces the aggregator pulled in.

Step 7 · Package a runnable JAR

Try running the JAR you already built:

Bash
java -jar target/bill-splitter-1.0-SNAPSHOT.jar 10000 ada bola chidi || true
java -cp target/classes com.example.split.App 10000 ada bola chidi || true

Both fail, as intended, and || true only keeps the expected failures from stopping a script. The first says no main manifest attribute: the JAR does not name a class to start. The second names the class by hand and gets further, then stops with NoClassDefFoundError: org/apache/commons/text/WordUtils, because your classes are there but Commons Text is not.

The Maven Shade plugin fixes both. During package it unpacks your compile-scope dependencies into one JAR with your classes, and writes the main class into the manifest. Rewrite pom.xml once more. Everything is as before, except for the new <plugins> block at the end of <build>:

Bash
cat > pom.xml <<'XML'
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>bill-splitter</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>bill-splitter</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.release>25</maven.compiler.release>
    <junit.version>6.1.3</junit.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-text</artifactId>
      <version>1.15.0</version>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.5.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.5.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.16.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.6.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.5.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.11.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-wrapper-plugin</artifactId>
          <version>3.3.4</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.6.2</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>com.example.split.App</mainClass>
                </transformer>
              </transformers>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>module-info.class</exclude>
                    <exclude>META-INF/versions/*/module-info.class</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
XML
mvn clean package
java -jar target/bill-splitter-1.0-SNAPSHOT.jar 10000 ada bola chidi

<pluginManagement> only pins versions; a plugin listed under <plugins> actually runs. The <execution> binds Shade's shade goal to the package phase, so it runs right after the jar plugin. The filter drops the libraries' module-info.class files, which describe each library as a separate Java module and mean nothing once everything shares one JAR. Shade may still warn that files such as META-INF/LICENSE.txt appear in more than one JAR; for this project that is harmless.

Check it worked

The app prints three lines: Ada pays 33.34, Bola pays 33.33 and Chidi pays 33.33. ls -lh target/*.jar shows two files: the runnable bill-splitter-1.0-SNAPSHOT.jar, now around a megabyte because it carries Commons Text and Commons Lang, and original-bill-splitter-1.0-SNAPSHOT.jar, the few-kilobyte JAR the jar plugin made before Shade replaced it.

Step 8 · Add the Maven Wrapper

Your build works with the Maven on your computer. A teammate, or a CI server, may have a different Maven or none. The Maven Wrapper is a small script, committed with your code, that downloads the exact Maven version the project names and runs it. Generate it for Maven 3.10.2:

Bash
mvn wrapper:wrapper -Dmaven=3.10.2
ls -a
cat .mvn/wrapper/maven-wrapper.properties
./mvnw -version

The plugin writes mvnw for Linux and macOS, mvnw.cmd for Windows, and .mvn/wrapper/maven-wrapper.properties, which holds the download address of Maven 3.10.2. The default only-script type adds no JAR to your repository: the script downloads Maven with curl or wget the first time and keeps it under ~/.m2/wrapper/dists. To move the whole team to a newer Maven later, run the same command with the new version and commit the changed properties file.

Check it worked

ls -a now shows mvnw and mvnw.cmd next to pom.xml. The properties file has a distributionUrl line ending in apache-maven-3.10.2-bin.zip and distributionType=only-script. ./mvnw -version prints Apache Maven 3.10.2, with a Maven home under ~/.m2/wrapper/dists, not /opt.

Step 9 · Prove the build on a fresh checkout

A build is only reproducible if it works from what is in version control, with no leftovers from your machine. Put the project in Git, keep target/ out of it, then clone it into a new folder the way a teammate would:

Bash
sudo apt install -y git
printf 'target/\n' > .gitignore
git init -q -b main
git add .
git -c user.name="Maven Demo" -c user.email="demo@example.com" commit -q -m "Bill splitter with Maven Wrapper"
git clone -q ~/maven-demo/bill-splitter ~/maven-demo/fresh-checkout
cd ~/maven-demo/fresh-checkout
ls -a

The -c options give this one commit a throwaway name and email. If Git already knows who you are, drop them. Now build the clone with the wrapper, not your installed Maven, and run the app it produced:

Bash
./mvnw clean verify
java -jar target/bill-splitter-1.0-SNAPSHOT.jar 2500 kemi tunde

verify is the phase to ask for when you want to know "is this change good": it compiles, tests, packages and runs any checks bound after packaging, without touching your local repository the way install does. It is the command most CI pipelines run.

Check it worked

ls -a in the clone shows mvnw, .mvn, pom.xml and src, but no target folder. ./mvnw clean verify reports Tests run: 6, Failures: 0, Errors: 0, Skipped: 0 and BUILD SUCCESS, and the app prints Kemi pays 12.50 and Tunde pays 12.50. Someone with only Java 25 and this repository can now build the project exactly as you do. On Windows they run mvnw.cmd clean verify instead.

Step 10 · Clean up

This leaves the demo folder first, then removes it, the copy of the app that mvn install put in your local repository, and the Maven the wrapper downloaded. The libraries and plugins in ~/.m2/repository stay cached for your next project:

Bash
cd ~
rm -rf ~/maven-demo
rm -rf ~/.m2/repository/com/example/bill-splitter
rm -rf ~/.m2/wrapper/dists/apache-maven-3.10.2

Keep Maven installed if you will carry on with Java. To remove it as well, run sudo rm /usr/local/bin/mvn /opt/maven and then sudo rm -rf /opt/apache-maven-3.10.2.

Check it worked

ls ~/maven-demo reports that there is no such file or directory, and mvn -version still prints Apache Maven 3.10.2.

Next steps

Need this done for you?

Padding does this work for growing companies, from the first diagnosis to a system that keeps working.

Platform Engineering

Get new tutorials

New tutorials, about twice a month.