Maven is a build tool. It doesn't help you much running the final application.

You can use mvn exec:java -Dexec.mainClass="com.example.Sandbox" to run your app (see the question Maven Run Project) but this gets tedious when you have to pass arguments to it.

You can get the classpath that Maven used to compile your application with mvn dependency:build-classpath

That will print the classpath to the console. Note that it will be missing target/notification-1.0.0.jar

Another useful tool in this area is the assembly plugin; it will create one very big JAR with all the dependencies rolled into a single file when you specify the descriptor jar-with-dependencies.

Answer from Aaron Digulla on Stack Overflow
🌐
Apache Maven
maven.apache.org › plugins-archives › maven-surefire-plugin-2.12.4 › examples › configuring-classpath.html
Configuring the Classpath - Apache Maven
This will be treated as an absolute file system path, so you may want use ${basedir} or another property combined with a relative path. Note that additional classpath elements are added to the end of the classpath, so you cannot use these to override project dependencies or resources. <project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12.4</version> <configuration> <additionalClasspathElements> <additionalClasspathElement>path/to/additional/resources</additionalClasspathElement> <additionalClasspathElement>path/to/additional/jar</additionalClasspathElement> </additionalClasspathElements> </configuration> </plugin> </plugins> </build> [...] </project> Dependencies can be removed from the test classpath using the parameters classpathDependencyExcludes and classpathDependencyScopeExclude.
🌐
Apache Maven
maven.apache.org › shared › maven-archiver › examples › classpath.html
Set Up The Classpath – Apache Maven Archiver
December 20, 2025 - <project> ... <build> <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> </manifest> </archive> </configuration> </plugin> </plugins> </build> ... <dependencies> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> <version>1.1</version> </dependency> </dependencies> ... </project> The manifest classpath produced using the above configuration would look like this: Class-Path: lib/plexus-utils-1.1.jar lib/commons-lang-2.1.jar ... Occasionally, you may want to include a Maven repository-style directory structure in your archive.
🌐
Guntherrotsch
guntherrotsch.github.io › blog_2020 › maven-classpath.html
Maven And The Classpath
When Maven's Surefire plugin executes unit tests of a project, developers do not need to provide the classpath containing all dependencies. Instead, Maven sets up the required classpath. Other plugins utilize the Maven generated classpath, too.
Top answer
1 of 7
122

To get the classpath all by itself in a file, you can:

mvn dependency:build-classpath -Dmdep.outputFile=cp.txt

Or add this to the POM.XML:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.9</version>
        <executions>
          <execution>
            <id>build-classpath</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>build-classpath</goal>
            </goals>
            <configuration>
              <!-- configure the plugin here -->
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

From: http://maven.apache.org/plugins/maven-dependency-plugin/usage.html

2 of 7
26

This command outputs the classpath on Mac and Linux:

mvn -q exec:exec -Dexec.executable=echo -Dexec.args="%classpath"

Having the result printed and not saved into a file might be useful, for instance, when assigning the result to a variable in a Bash script. This solution runs on Mac and Linux only, but so do Bash shell scripts.

In Windows (e.g. in BAT files), where there is no echo executable, you will need something like this (untested):

mvn -q exec:exec -Dexec.executable=cmd -Dexec.args="/c echo %classpath"

Alternatively, you can just execute java program with the classpath:

mvn -q exec:exec -Dexec.executable=java -Dexec.args="-cp %classpath Main"

Or even like that (it will use the correct classpath automatically):

mvn -q exec:java -Dexec.mainClass="Main" 

However, both these alternative approaches suffer from Maven adding its error messages when your program fails.

🌐
Apache Maven
maven.apache.org › plugins › maven-dependency-plugin › build-classpath-mojo.html
dependency:build-classpath – Apache Maven Dependency Plugin
February 5, 2026 - This goal outputs a classpath string of dependencies from the local repository to a file or log. ... Requires a Maven project to be executed. Requires dependency resolution of artifacts in scope: test.
🌐
rupalchatterjee
rupalchatterjee.wordpress.com › tag › create-classpath-and-project-file-in-maven
create .classpath and .project file in maven – rupalchatterjee
May 21, 2013 - .classpath & .project should be created inside “HelloWorldMaven” folder. These are the files required by eclipse for proper import. 2. Now when our maven is eclipse ready then our next job is to import it in Eclipse IDE.
Find elsewhere
🌐
Apache Maven
maven.apache.org › surefire › maven-surefire-plugin › examples › configuring-classpath.html
Configuring the Classpath – Maven Surefire Plugin
The items will be treated as absolute file system paths, so you may want use ${basedir} or another property combined with a relative path. Note that additional classpath elements are added to the end of the classpath, so you cannot use these to override project dependencies or resources. <project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.5.6</version> <configuration> <additionalClasspathElements> <additionalClasspathElement>path/to/additional/resources</additionalClasspathElement> <additionalClasspathElement>path/to/additional/jar</additionalClasspathElement> <additionalClasspathElement>path/to/csv/jar1, path/to/csv/jar2</additionalClasspathElement> </additionalClasspathElements> </configuration> </plugin> </plugins> </build> [...] </project>
🌐
Pdfunit
pdfunit.com › en › documentation › java › install_update › classpath.html
12.3. Setting Classpath in Eclipse, ANT, Maven
To use it with Maven despite this fact, you have to install it into a local or company-wide repository. You can do it with the following command. Change to the directory PDFUNIT_HOME\lib and run this command: mvn install:install-file -Dfile=<PATH_TO>pdfunit-java-VERSION.jar -DpomFile=<PATH_TO>pom.xml · The next step is to copy pdfunit.config into the directory src/test/resources. The following image shows the resulting project layout:
🌐
Coderanch
coderanch.com › t › 623040 › build-tools › beginner-maven-classpath-deployment
beginner maven question classpath and deployment (Other Build Tools forum at Coderanch)
November 3, 2013 - Jim, It's good you posted as you made progress. Others new to Maven will learn based on what you tried. You might be past this, but I'm not sure: Maven doesn't use the .classpath, it just uses the POM. In Eclipse, you right click the project, select Maven and then Maven Update Project.
🌐
Stack Overflow
stackoverflow.com › questions › 2367497 › add-maven-classpath
java - Add Maven Classpath - Stack Overflow
28 Maven: add a folder or jar file into current classpath · 3 How to add class files to a Maven2 project · 28 Maven does not add classpath to Eclipse project · 7 Add generated build file to classpath · 0 Modify Maven's classpath · 3 How to add non-jar files to classpath in Maven project?
🌐
Wordpress
vishwanathk.wordpress.com › 2011 › 05 › 05 › resolving-classpath-issues-with-eclipse-maven
Resolving classpath issues with Eclipse + Maven | Vishwanath Krishnamurthi's blog
October 2, 2013 - Right-Click the project –> Build Path –> Configure Build Path –> Source Tab –> Choose the file-patterns you want to include –> Click edit. ... The same dialog-box helps you to exclude file-patterns.
🌐
Nabble
maven.40175.n5.nabble.com › How-to-add-class-file-to-build-amp-classpath-td5904852.html
Maven - Users - How to add class file to build & classpath?
June 4, 2017 - Maven › Maven - Users · ‹ Previous Topic Next Topic › · ♦ · ♦ Locked 10 messages · David Hoffer · Reply | Threaded · Open this post in threaded view · ♦ · ♦ | Curtis Rueden · Reply | Threaded · Open this post in threaded view · ♦ · ♦ | David Hoffer ·
🌐
Apache Maven
maven.apache.org › shared-archives › maven-archiver-2.5 › examples › classpath.html
Set Up The Classpath
<dependencies> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> <version>1.1</version> </dependency> </dependencies> ... </project> The manifest classpath produced using the above configuration would look like this: Class-Path: lib/plexus-utils-1.1.jar lib/commons-lang-2.1.jar ... Occasionally, you may want to include a Maven repository-style directory structure in your archive.
🌐
Apache Maven
maven.apache.org › plugins › maven-antrun-plugin › examples › classpaths.html
Using the classpaths – Apache Maven AntRun Plugin
<project> <modelVersion>4.0.0</modelVersion> <artifactId>my-test-app</artifactId> <groupId>my-test-group</groupId> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>compile</id> <phase>compile</phase> <configuration> <target> <property name="compile_classpath" refid="maven.compile.classpath"/> <property name="runtime_classpath" refid="maven.runtime.classpath"/> <property name="test_classpath" refid="maven.test.classpath"/> <property name="plugin_classpath" refid="maven.plugin.classpath"/> <ant antfile="${basedir}/build.xml"> <target name="test"/> </ant> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
🌐
Diffblue
docs.diffblue.com › knowledge-base › cli › passing-classpath
Cover CLI | Diffblue Documentation
Patch files · Diffblue Sandbox · Operational behaviors · Test validation · Project configuration · Preflight checks · General dependencies · Test framework dependencies · Compiling your project successfully · Building a Maven project · Building a Gradle project ·