Andrew
Andrew

Reputation: 103

Command Line Options for Java Class in IntelliJ

I'm using IntelliJ to run some data analysis classes but I'm not that familiar with Java itself. Unlike the Java classes that I've run before, this one apparently required some "Config options".

Here's the first few lines of the code:

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();
    }

To run the class I specified a inputPath followed by an outputPath in the "Program arguments" line. I guess cmd.hasOption wants me to specify either a population or a facilities file.

How do I pass on this option? Is there a special syntax for that?

Upvotes: 0

Views: 89

Answers (1)

Farvardin
Farvardin

Reputation: 5424

You need to provide one of these option as program arguments:

--facilities or --population

example:

java Class --facilities inputPath outputPath 

or java Class --population inputPath outputPath

Upvotes: 1

Related Questions