<dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
Options options = new Options();
Option inputOption = new Option("i", "input", true, "Input file path");
inputOption.setRequired(true);
options.addOption(inputOption);
Option outputOption = new Option("o", "output", true, "Output file path");
outputOption.setRequired(true);
options.addOption(outputOption);
CommandLineParser parser = new DefaultParser();
try {
CommandLine cmd = parser.parse(options, args);
String inputFilePath = cmd.getOptionValue("input");
String outputFilePath = cmd.getOptionValue("output");
// ...
} catch (ParseException e) {
System.out.println("Invalid command line arguments. Please provide the required options.");
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("myprogram", options);
System.exit(1);
}