List of usage examples for org.apache.commons.cli MissingArgumentException getOption
public Option getOption()
From source file:org.eclipse.jetty.Starter.java
/** * Starts the jetty server using the war file in which this class is embedded *//*from w w w . ja va 2s . c o m*/ public static void main(String[] args) { Options options = buildOptions(); CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(options, args); String hostname = cmd.getOptionValue('h', "localhost"); int port = parsePort(cmd); if (cmd.hasOption('l')) { String loggingFile = cmd.getOptionValue('l'); if (!new File(loggingFile).exists()) { System.out.println( "The provided logging configuration file " + loggingFile + " does not exists!"); printHelp(options); return; } System.setProperty("log4j.configuration", "file:" + loggingFile); } if (cmd.hasOption('c')) { String propertiesFile = cmd.getOptionValue('c'); if (!new File(propertiesFile).exists()) { System.out.println("The provided properties file " + propertiesFile + " does not exists!"); printHelp(options); return; } System.setProperty("configFile", propertiesFile); } startServer(hostname, port); } catch (MissingArgumentException mae) { System.out.println("The option " + mae.getOption().getOpt() + " is missing required argument!"); printHelp(options); } catch (UnrecognizedOptionException uoe) { System.out.println("Usage of unsupported option " + uoe.getOption() + "!"); printHelp(options); } catch (ParseException pe) { System.out.println("Wrong command line arguments provided!"); printHelp(options); } }