Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IntelliJ中Java类的命令行选项_Java_Intellij Idea - Fatal编程技术网

IntelliJ中Java类的命令行选项

IntelliJ中Java类的命令行选项,java,intellij-idea,Java,Intellij Idea,我使用IntelliJ运行一些数据分析类,但我对Java本身不太熟悉。 与我以前运行过的Java类不同,这个类显然需要一些配置选项 以下是代码的前几行: public class CountWorkplaces { static public void main(String[] args) throws IOException { CommandLineConfigurator cmd = new CommandLineConfigurator(args); String in

我使用IntelliJ运行一些数据分析类,但我对Java本身不太熟悉。 与我以前运行过的Java类不同,这个类显然需要一些配置选项

以下是代码的前几行:

public class CountWorkplaces {
static public void main(String[] args) throws IOException {
    CommandLineConfigurator cmd = new CommandLineConfigurator(args);
    String inputPath = cmd.getArguments().get(0);
    String outputPath = cmd.getArguments().get(1);

    if (!(cmd.hasOption("population") ^ cmd.hasOption("facilities"))) {
        throw new IllegalArgumentException();
    }
为了运行这个类,我在程序参数行中指定了一个inputPath,后跟一个outputPath。我猜cmd.haspoption希望我指定一个填充文件或一个设施文件


如何传递此选项?有专门的语法吗?

您需要提供以下选项之一作为程序参数:

-设施或人口

例如:

java Class --facilities inputPath outputPath 

java类-填充inputPath outputPath

出于好奇,CommandLineConfigurator这是库类还是用户定义类?它似乎是一个用户定义类,包含在我提供的包中。