Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8233415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:07:26+00:00 2026-06-07T18:07:26+00:00

I am using apache commons.cli library to parse the command line arguments. The default

  • 0

I am using apache commons.cli library to parse the command line arguments. The default parsing behavior is that it parses the arguments based on space. I am using ant to pass arguments to my Java program and the ant is using a slightly different syntax and is using = instead of space. How can I change the behavior of my parsing that it parses based on =
and not space ?
My parsing currently looks like this :

    Options options = new Options();
    options.addOption("Dkey", true, "some parameter");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:07:29+00:00Added an answer on June 7, 2026 at 6:07 pm

    Have a look at the usage examples page, especially the Ant example.

    You could use the OptionBuilder and create an option for D which has 2 arguments.

    For your case the adapted example from that page could look like this:

    Option property  = OptionBuilder.withArgName( "key=value" )
                                .hasArgs(2)
                                .withValueSeparator()
                                .withDescription( "use value for given property" )
                                .create( "D" );
    

    Here’s the relevant JavaDoc with another example: http://commons.apache.org/cli/api-1.2/org/apache/commons/cli/OptionBuilder.html#withValueSeparator%28%29

    Option opt = OptionBuilder.withValueSeparator().create('D');
    
    CommandLine line = parser.parse(args);
    String propertyName = opt.getValue(0);
    String propertyValue = opt.getValue(1);   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Apache commons cli (1.2) for command line parsing. I have the
I am using Apache commons CLI for command line parsing in a Scala utility
I am using apache commons-net for downloading a file from an FTP server. That
I am using Apache Commons Email library to send emails, but I am not
I'm using apache commons library and log4j. I have an xml configuration file and
I'm using Apache Commons Configuration library to store my app properties. I can monitor
I am using Apache Commons HttpClient 3.1, and I found that HttpURLConnection from Sun
I have a simple form that uploads a selected file using Apache Commons Upload
I have a working prototype of a Java application that is using Apache Commons
I'm using Apache Commons Exec and trying to start subprocess that would work for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.