Java Apache Commons CLI 找不到 setArgs()

Java Apache Commons CLI does not find setArgs()

我正在尝试将多个参数传递给 java 程序。 Apache Commons CLI 界面已正确设置并正常工作。但是,当我尝试使用

setArgs(Option.UNLIMITED_VALUES),它给我一个错误

The method setArgs(int) is undefined for the type Options.

我的代码如下所示:

import java.io.Console;
import java.util.Arrays;
import java.io.IOException;
import org.apache.commons.cli.*;


public class main {

public static void main(String[] args) {

    @SuppressWarnings("deprecation")
    CommandLineParser parser = new BasicParser();

    Options options = new Options();
    options.setArgs(Option.UNLIMITED_VALUES);   
    options.addOption("p", true, "Program under test");
    options.addOption("o", true, "Oracle");
    options.addOption("n", true, "Number of test cases");

    try {
        CommandLine commandline = parser.parse(options, args);

        System.out.println(commandline.getOptionValue("p"));

    } catch (ParseException e) {
        System.out.println("Command line failed.");
        e.printStackTrace();
    }

}

}

setArgs 是与 Option 相关的方法,而不是 Options