Common Java Cookbook

Edition: 0.19

Download PDF or Read on Scribd

Download Examples (ZIP)

1.1. Depending on Commons CLI

1.1.1. Problem

You need to use Commons CLI (Command-Line Interface) to parse an application's command-line arguments.

1.1.2. Solution

To use Commons CLI 1.1 in a Maven 2 project, add the following dependency to your project's pom.xml:

Example 7.1. Adding a Dependency on Commons CLI

<dependency>
    	<groupId>commons-cli</groupId>
    	<artifactId>commons-cli</artifactId>
    	<version>1.1</version>
    </dependency>

1.1.3. Discussion

If you are not sure what this means, I'd suggest reading Maven: The Definitive Guide. When you depend on a library in Maven 2, all you need to do is add the dependency groupId, artifactId, and version to your project's dependencies. Once you do this, Maven 2 will download the dependency and make it available on your project's classpath.

1.1.4. See Also

For more information about the Commons CLI project, see the Commons CLI project page at http://commons.apache.org/cli.


Creative Commons License
Common Java Cookbook by Tim O'Brien is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
Permissions beyond the scope of this license may be available at http://www.discursive.com/books/cjcook/reference/jakartackbk-PREFACE-1.html. Copyright 2009. Common Java Cookbook Chunked HTML Output. Some Rights Reserved.