I cannot reproduce. After adding JAR file to dependencies and adding an import statement on top of the class file everything worked as expected. Maybe try to change scope?

Dependencies:

Class file:

Answer from Renats Stozkovs on Stack Overflow
🌐
Apache Commons
commons.apache.org › cli › download_cli.cgi
Download Apache Commons CLI – Apache Commons CLI
November 8, 2025 - Apache Commons, Apache Commons CLI, Apache, the Apache logo, and the Apache Commons project logos are trademarks of The Apache Software Foundation.
🌐
GitHub
github.com › apache › commons-cli
GitHub - apache/commons-cli: Apache Commons CLI · GitHub
Apache Commons CLI provides a simple API for presenting, processing, and validating a Command Line Interface.
Starred by 389 users
Forked by 249 users
Languages   Java 97.4% | JavaScript 2.4%
🌐
TutorialsPoint
tutorialspoint.com › commons_cli › commons_cli_quick_guide.htm
Apache Commons CLI - Quick Guide
Eclipse − It is also a Java IDE developed by the eclipse open-source community and can be downloaded from www.eclipse.org. Download the latest version of Apache Common IO jar file from commons-cli-1.10.0-bin.zip.
🌐
Apache Commons
commons.apache.org › cli
Apache Commons CLI – Apache Commons CLI
November 8, 2025 - Apache Commons, Apache Commons CLI, Apache, the Apache logo, and the Apache Commons project logos are trademarks of The Apache Software Foundation.
🌐
Maven Repository
mvnrepository.com › artifact › commons-cli › commons-cli
Maven Repository: commons-cli » commons-cli
November 13, 2025 - Apache Commons CLI provides a simple API for presenting, processing, and validating a Command Line Interface.
🌐
Apache Commons
commons.apache.org › proper › commons-cli › dependency-info.html
Maven Coordinates – Apache Commons CLI
July 30, 2025 - Apache Commons, Apache Commons CLI, Apache, the Apache logo, and the Apache Commons project logos are trademarks of The Apache Software Foundation.
🌐
Eclipse
download.eclipse.org › staging › 2026-06 › buildInfo › archive › download.eclipse.org › staging › 2026-06 › index › org.apache.commons.cli_1.11.0.html
org.apache.commons.cli 1.11.0
<unit id="org.apache.commons.cli" ...//commons.apache.org/proper/commons-cli/"/> <property name="maven-groupId" value="commons-cli"/> <property name="maven-artifactId" value="commons-cli"/> <property name="maven-version" value="1.11.0"/> <property name="maven-repository" value="eclipse.maven.central.mirror"/> <property name="maven-type" value="jar"/> </properties> ...
🌐
Maven Central
central.sonatype.com › artifact › commons-cli › commons-cli
Maven Central: commons-cli:commons-cli
<artifactId>junit-pioneer</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.21.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-text</artifactId> <version>1.14.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>${commons.mockito.version}</version> <scope>test</scope> </dependency> </dependencies> <properties> <!-- project.build.outputTimestamp is managed by
Find elsewhere
🌐
Opensource.com
opensource.com › article › 21 › 8 › java-commons-cli
Parse command options in Java with commons-cli | Opensource.com
August 13, 2021 - Add that JAR to your project, either manually or in your IDE, and then you can use it in your code. To use the commons-cli library in your code, you must import it. For this simple option parsing example, you can populate a file called Main.java ...
🌐
Maven Repository
mvnrepository.com › artifact › commons-cli › commons-cli › 1.2
Maven Repository: commons-cli » commons-cli » 1.2
Apache Commons CLI provides a simple API for presenting, processing, and validating a Command Line Interface.
🌐
Maven Repository
mvnrepository.com › artifact › org.apache.commons › cli › 1.2.0
Maven Repository: org.apache.commons » cli » 1.2.0
June 27, 2013 - Home » org.apache.commons » cli » 1.2.0 · Apache Commons CLI · LicenseApache · Tagsapachecommand-linecommons · Links · DateJun 27, 2013 · Filespom (840 bytes)jar (53 KB)View All · RepositoriesJabylon · Ranking · #910289in MvnRepository · 💡 · Newer Version Available ·
Published   Jun 27, 2013
Version   1.2.0
🌐
Apache
projects.apache.org › project.html
Apache Commons CLI - Apache Projects
This site relies heavily on JavaScript. Please enable it or get a browser that supports it · Managed by the Apache Community Development Project. Copyright© the Apache Software Foundation. Licensed under the Apache License, Version 2.0 Apache® and the Apache logo are trademarks of The Apache ...
🌐
Baeldung
baeldung.com › home › java › intro to the apache commons cli
Intro to the Apache Commons CLI | Baeldung
February 20, 2025 - The library can speed up the development of CLIs with its support for defining the CLI options and basic validation of them. It helps parse the command line arguments and their values. Finally, the argument values can be passed to the underlying services implementing the tool. Notably, the Apache Commons CLI library is also used in several of Apache’s products, including Kafka, Maven, Ant, and Tomcat.
🌐
Findjar
findjar.com › jar › commons-cli › commons-cli › 1.2 › commons-cli-1.2.jar.html
commons-cli-1.2.jar - JAR Search - findJAR.com
March 19, 2009 - This page shows details for the JAR file commons-cli-1.2.jar contained in commons-cli/commons-cli/1.2. Apart from vendor, name and version also the contained classes and JAR dependencies are listed.
Top answer
1 of 4
7

You are using maven but you are running the application from command line so you need to provide all the required jars to your application:

Approach 1: You can provide into your classpath like below:

$ java -jar -cp "list-of-jars" target/my-app.jar -csv test.csv

If you are on Windows the path will be semi colon separated and on Linux it will colon separated. You can use wild cards also like /*.jar to include all the jars(java6+).

Approach 2: You can use one fat/uber/one jar to combine all the jars into on jar run it like you want.

Below is using one-jar:

Using Maven: you need to update the plugins section pom.xml:

<plugin>
        <groupId>org.dstovall</groupId>
        <artifactId>onejar-maven-plugin</artifactId>
        <version>1.4.4</version>
        <executions>
          <execution>
            <goals>
                <goal>one-jar</goal>
            </goals>
          </execution>
        </executions>
    </plugin>

And update pluginRepositories section in pom.xml

<pluginRepository>
        <id>onejar-maven-plugin.googlecode.com</id>
        <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginRepository>

When you will execute the mvn package you will get yourappname-one-jar.jar and you can run it java -jar yourappname-one-jar.jar

Approach 3: To use the maven shade plugin (as Robert suggested):

Add this into the plugins section of pom.xml:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.1</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>org.sonatype.haven.HavenCli</mainClass>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>

Upon execution on mvn package the uber jar will be generated.

2 of 4
0

Using maven-dependency-plugin is a solution.

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.8</version>
    <executions>
        <execution>
             <id>copy-dependencies</id>
             <phase>package</phase>
             <goals>
                 <goal>copy-dependencies</goal>
             </goals>
             <configuration>
                 <outputDirectory>${project.build.directory}/lib</outputDirectory>
             </configuration>
        </execution>
     </executions>
</plugin>
🌐
Stack Overflow
stackoverflow.com › questions › 51578836 › command-line-arguments-using-apache-common-cli-and-maven
java - Command line arguments using apache common cli and maven - Stack Overflow
I am trying to build small jar using common cli but i am getting this error after building jar and when i run this command. java -jar validator.jar · Error: CopyException in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/Options at com.kir.App.main(App.java:10) Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.Options at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ...
🌐
FreshPorts
freshports.org › java › apache-commons-cli
FreshPorts -- java/apache-commons-cli: Java library for command line arguments and options
The Apache Commons CLI library provides a simple and easy to use API for working with the command line arguments and options.