List of usage examples for org.apache.commons.cli CommandLine hasOption
public boolean hasOption(char opt)
From source file:edu.cmu.lti.oaqa.knn4qa.apps.CollectionSplitter.java
public static void main(String[] args) { Options options = new Options(); options.addOption("i", null, true, "Input file"); options.addOption("o", null, true, "Output file prefix"); options.addOption("p", null, true, "Comma separated probabilities e.g., 0.1,0.2,0.7."); options.addOption("n", null, true, "Comma separated part names, e.g., dev,test,train"); CommandLineParser parser = new org.apache.commons.cli.GnuParser(); try {/*w w w . j a va2 s. co m*/ CommandLine cmd = parser.parse(options, args); InputStream input = null; if (cmd.hasOption("i")) { input = CompressUtils.createInputStream(cmd.getOptionValue("i")); } else { Usage("Specify Input file"); } ArrayList<Double> probs = new ArrayList<Double>(); String[] partNames = null; if (cmd.hasOption("p")) { String parts[] = cmd.getOptionValue("p").split(","); try { double sum = 0; for (String s : parts) { double p = Double.parseDouble(s); if (p <= 0 || p > 1) Usage("All probabilities must be in the range (0,1)"); sum += p; probs.add(p); } if (Math.abs(sum - 1.0) > Float.MIN_NORMAL) { Usage("The sum of probabilities should be equal to 1, but it's: " + sum); } } catch (NumberFormatException e) { Usage("Can't convert some of the probabilities to a floating-point number."); } } else { Usage("Specify part probabilities."); } if (cmd.hasOption("n")) { partNames = cmd.getOptionValue("n").split(","); if (partNames.length != probs.size()) Usage("The number of probabilities is not equal to the number of parts!"); } else { Usage("Specify part names"); } BufferedWriter[] outFiles = new BufferedWriter[partNames.length]; if (cmd.hasOption("o")) { String outPrefix = cmd.getOptionValue("o"); for (int partId = 0; partId < partNames.length; ++partId) { outFiles[partId] = new BufferedWriter(new OutputStreamWriter( CompressUtils.createOutputStream(outPrefix + "_" + partNames[partId] + ".gz"))); } } else { Usage("Specify Output file prefix"); } System.out.println("Using probabilities:"); for (int partId = 0; partId < partNames.length; ++partId) System.out.println(partNames[partId] + " : " + probs.get(partId)); System.out.println("================================================="); XmlIterator inpIter = new XmlIterator(input, YahooAnswersReader.DOCUMENT_TAG); String oneRec = inpIter.readNext(); int docNum = 1; for (; !oneRec.isEmpty(); ++docNum, oneRec = inpIter.readNext()) { double p = Math.random(); if (docNum % 1000 == 0) { System.out.println(String.format("Processed %d documents", docNum)); } BufferedWriter out = null; for (int partId = 0; partId < partNames.length; ++partId) { double pp = probs.get(partId); if (p <= pp || partId + 1 == partNames.length) { out = outFiles[partId]; break; } p -= pp; } oneRec = oneRec.trim() + System.getProperty("line.separator"); out.write(oneRec); } System.out.println(String.format("Processed %d documents", docNum - 1)); // It's important to close all the streams here! for (BufferedWriter f : outFiles) f.close(); } catch (ParseException e) { Usage("Cannot parse arguments"); } catch (Exception e) { System.err.println("Terminating due to an exception: " + e); System.exit(1); } }
From source file:edu.umass.cs.gnsclient.client.testing.ReplicaLatencyTest.java
/** * The main routine run from the command line. * * @param args//from w ww .ja v a 2s.co m * @throws Exception */ public static void main(String args[]) throws Exception { try { CommandLine parser = initializeOptions(args); if (parser.hasOption("help") || args.length == 0) { printUsage(); System.exit(1); } String alias = parser.getOptionValue("alias"); String host = parser.getOptionValue("host"); String port = parser.getOptionValue("port"); boolean debug = parser.hasOption("debug"); String closeActiveReplica = parser.getOptionValue("closeAR"); ReplicaLatencyTest test = new ReplicaLatencyTest(alias, host, port); // Need this on to read the which replica is responding //client.setEnableInstrumentation(true); test.findSlowGuid(closeActiveReplica); // send the reads and writes test.readsAndWrites(closeActiveReplica); //test.removeSubGuid(); client.close(); System.exit(0); } catch (HeadlessException e) { System.out .println("When running headless you'll need to specify the host and port on the command line"); printUsage(); System.exit(1); } }
From source file:ISMAGS.CommandLineInterface.java
public static void main(String[] args) throws IOException { String folder = null, files = null, motifspec = null, output = null; Options opts = new Options(); opts.addOption("folder", true, "Folder name"); opts.addOption("linkfiles", true, "Link files seperated by spaces (format: linktype[char] directed[d/u] filename)"); opts.addOption("motif", true, "Motif description by two strings (format: linktypes)"); opts.addOption("output", true, "Output file name"); CommandLineParser parser = new PosixParser(); try {/* w w w. j a va 2s. c o m*/ CommandLine cmd = parser.parse(opts, args); if (cmd.hasOption("folder")) { folder = cmd.getOptionValue("folder"); } if (cmd.hasOption("linkfiles")) { files = cmd.getOptionValue("linkfiles"); } if (cmd.hasOption("motif")) { motifspec = cmd.getOptionValue("motif"); } if (cmd.hasOption("output")) { output = cmd.getOptionValue("output"); } } catch (ParseException e) { Die("Error: Parsing error"); } if (print) { printBanner(folder, files, motifspec, output); } if (folder == null || files == null || motifspec == null || output == null) { Die("Error: not all options are provided"); } else { ArrayList<String> linkfiles = new ArrayList<String>(); ArrayList<String> linkTypes = new ArrayList<String>(); ArrayList<String> sourcenetworks = new ArrayList<String>(); ArrayList<String> destinationnetworks = new ArrayList<String>(); ArrayList<Boolean> directed = new ArrayList<Boolean>(); StringTokenizer st = new StringTokenizer(files, " "); while (st.hasMoreTokens()) { linkTypes.add(st.nextToken()); directed.add(st.nextToken().equals("d")); sourcenetworks.add(st.nextToken()); destinationnetworks.add(st.nextToken()); linkfiles.add(folder + st.nextToken()); } ArrayList<LinkType> allLinkTypes = new ArrayList<LinkType>(); HashMap<Character, LinkType> typeTranslation = new HashMap<Character, LinkType>(); for (int i = 0; i < linkTypes.size(); i++) { String n = linkTypes.get(i); char nn = n.charAt(0); LinkType t = typeTranslation.get(nn); if (t == null) { t = new LinkType(directed.get(i), n, i, nn, sourcenetworks.get(i), destinationnetworks.get(i)); } allLinkTypes.add(t); typeTranslation.put(nn, t); } if (print) { System.out.println("Reading network.."); } Network network = Network.readNetworkFromFiles(linkfiles, allLinkTypes); Motif motif = getMotif(motifspec, typeTranslation); if (print) { System.out.println("Starting the search.."); } MotifFinder mf = new MotifFinder(network); long tijd = System.nanoTime(); Set<MotifInstance> motifs = mf.findMotif(motif, false); tijd = System.nanoTime() - tijd; if (print) { System.out.println("Completed search in " + tijd / 1000000 + " milliseconds"); } if (print) { System.out.println("Found " + motifs.size() + " instances of " + motifspec + " motif"); } if (print) { System.out.println("Writing instances to file: " + output); } printMotifs(motifs, output); if (print) { System.out.println("Done."); } // Set<MotifInstance> motifs=null; // MotifFinder mf=null; // System.out.println("Starting the search.."); // long tstart = System.nanoTime(); // for (int i = 0; i < it; i++) { // // mf = new MotifFinder(network, allLinkTypes, true); // motifs = mf.findMotif(motif); // } // // long tend = System.nanoTime(); // double time_in_ms = (tend - tstart) / 1000000.0; // System.out.println("Found " + mf.totalFound + " motifs, " + time_in_ms + " ms"); //// System.out.println("Evaluated " + mf.totalNrMappedNodes+ " search nodes"); //// System.out.println("Found " + motifs.size() + " motifs, " + time_in_ms + " ms"); // printMotifs(motifs, output); } }
From source file:be.dnsbelgium.rdap.client.RDAPCLI.java
public static void main(String[] args) { LOGGER.debug("Create the command line parser"); CommandLineParser parser = new GnuParser(); LOGGER.debug("Create the options"); Options options = new RDAPOptions(Locale.ENGLISH); try {/*from www .j a va 2 s.c om*/ LOGGER.debug("Parse the command line arguments"); CommandLine line = parser.parse(options, args); if (line.hasOption("help")) { printHelp(options); return; } if (line.getArgs().length == 0) { throw new IllegalArgumentException("You must provide a query"); } String query = line.getArgs()[0]; Type type = (line.getArgs().length == 2) ? Type.valueOf(line.getArgs()[1].toUpperCase()) : guessQueryType(query); LOGGER.debug("Query: {}, Type: {}", query, type); try { SSLContextBuilder sslContextBuilder = SSLContexts.custom(); if (line.hasOption(RDAPOptions.TRUSTSTORE)) { sslContextBuilder.loadTrustMaterial( RDAPClient.getKeyStoreFromFile(new File(line.getOptionValue(RDAPOptions.TRUSTSTORE)), line.getOptionValue(RDAPOptions.TRUSTSTORE_TYPE, RDAPOptions.DEFAULT_STORETYPE), line.getOptionValue(RDAPOptions.TRUSTSTORE_PASS, RDAPOptions.DEFAULT_PASS))); } if (line.hasOption(RDAPOptions.KEYSTORE)) { sslContextBuilder.loadKeyMaterial( RDAPClient.getKeyStoreFromFile(new File(line.getOptionValue(RDAPOptions.KEYSTORE)), line.getOptionValue(RDAPOptions.KEYSTORE_TYPE, RDAPOptions.DEFAULT_STORETYPE), line.getOptionValue(RDAPOptions.KEYSTORE_PASS, RDAPOptions.DEFAULT_PASS)), line.getOptionValue(RDAPOptions.KEYSTORE_PASS, RDAPOptions.DEFAULT_PASS).toCharArray()); } SSLContext sslContext = sslContextBuilder.build(); final String url = line.getOptionValue(RDAPOptions.URL); final HttpHost host = Utils.httpHost(url); HashSet<Header> headers = new HashSet<Header>(); headers.add(new BasicHeader("Accept-Language", line.getOptionValue(RDAPOptions.LANG, Locale.getDefault().toString()))); HttpClientBuilder httpClientBuilder = HttpClients.custom().setDefaultHeaders(headers) .setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext, (line.hasOption(RDAPOptions.INSECURE) ? new AllowAllHostnameVerifier() : new BrowserCompatHostnameVerifier()))); if (line.hasOption(RDAPOptions.USERNAME) && line.hasOption(RDAPOptions.PASSWORD)) { BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(new AuthScope(host.getHostName(), host.getPort()), new UsernamePasswordCredentials(line.getOptionValue(RDAPOptions.USERNAME), line.getOptionValue(RDAPOptions.PASSWORD))); httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); } RDAPClient rdapClient = new RDAPClient(httpClientBuilder.build(), url); ObjectMapper mapper = new ObjectMapper(); JsonNode json = null; switch (type) { case DOMAIN: json = rdapClient.getDomainAsJson(query); break; case ENTITY: json = rdapClient.getEntityAsJson(query); break; case AUTNUM: json = rdapClient.getAutNum(query); break; case IP: json = rdapClient.getIp(query); break; case NAMESERVER: json = rdapClient.getNameserver(query); break; } PrintWriter out = new PrintWriter(System.out, true); if (line.hasOption(RDAPOptions.RAW)) { mapper.writer().writeValue(out, json); } else if (line.hasOption(RDAPOptions.PRETTY)) { mapper.writer(new DefaultPrettyPrinter()).writeValue(out, json); } else if (line.hasOption(RDAPOptions.YAML)) { DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setPrettyFlow(true); dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); dumperOptions.setSplitLines(true); Yaml yaml = new Yaml(dumperOptions); Map data = mapper.convertValue(json, Map.class); yaml.dump(data, out); } else { mapper.writer(new MinimalPrettyPrinter()).writeValue(out, json); } out.flush(); } catch (Exception e) { LOGGER.error(e.getMessage(), e); System.exit(-1); } } catch (org.apache.commons.cli.ParseException e) { printHelp(options); System.exit(-1); } }
From source file:net.sf.mpaxs.test.ImpaxsExecution.java
/** * * @param args//from w ww. ja v a 2 s. c o m */ public static void main(String[] args) { Options options = new Options(); Option[] optionArray = new Option[] { OptionBuilder.withArgName("nhosts").hasArg() .withDescription("Number of hosts for parallel processing").create("n"), OptionBuilder.withArgName("mjobs").hasArg().withDescription("Number of jobs to run in parallel") .create("m"), OptionBuilder.withArgName("runmode").hasArg() .withDescription("The mode in which to operate: one of <ALL,LOCAL,DISTRIBUTED>") .create("r"), // OptionBuilder.withArgName("gui"). // withDescription("Create gui for distributed execution").create("g") }; for (Option opt : optionArray) { options.addOption(opt); } if (args.length == 0) { HelpFormatter hf = new HelpFormatter(); hf.printHelp(StartUp.class.getCanonicalName(), options, true); System.exit(1); } GnuParser gp = new GnuParser(); int nhosts = 1; int mjobs = 10; boolean gui = false; Mode mode = Mode.ALL; try { CommandLine cl = gp.parse(options, args); if (cl.hasOption("n")) { nhosts = Integer.parseInt(cl.getOptionValue("n")); } if (cl.hasOption("m")) { mjobs = Integer.parseInt(cl.getOptionValue("m")); } if (cl.hasOption("r")) { mode = Mode.valueOf(cl.getOptionValue("r")); } // if (cl.hasOption("g")) { // gui = true; // } } catch (Exception ex) { Logger.getLogger(StartUp.class.getName()).log(Level.SEVERE, null, ex); HelpFormatter hf = new HelpFormatter(); hf.printHelp(StartUp.class.getCanonicalName(), options, true); System.exit(1); } String version; try { version = net.sf.mpaxs.api.Version.getVersion(); System.out.println("Running mpaxs " + version); File computeHostJarLocation = new File(System.getProperty("user.dir"), "mpaxs.jar"); if (!computeHostJarLocation.exists() || !computeHostJarLocation.isFile()) { throw new IOException("Could not locate mpaxs.jar in " + System.getProperty("user.dir")); } final PropertiesConfiguration cfg = new PropertiesConfiguration(); //set default execution type cfg.setProperty(ConfigurationKeys.KEY_EXECUTION_MODE, ExecutionType.DRMAA); //set location of compute host jar cfg.setProperty(ConfigurationKeys.KEY_PATH_TO_COMPUTEHOST_JAR, computeHostJarLocation); //do not exit to console when master server shuts down cfg.setProperty(ConfigurationKeys.KEY_MASTER_SERVER_EXIT_ON_SHUTDOWN, false); //limit the number of used compute hosts cfg.setProperty(ConfigurationKeys.KEY_MAX_NUMBER_OF_CHOSTS, nhosts); cfg.setProperty(ConfigurationKeys.KEY_NATIVE_SPEC, ""); cfg.setProperty(ConfigurationKeys.KEY_GUI_MODE, gui); cfg.setProperty(ConfigurationKeys.KEY_SILENT_MODE, true); cfg.setProperty(ConfigurationKeys.KEY_SCHEDULE_WAIT_TIME, "500"); final int maxJobs = mjobs; final int maxThreads = nhosts; final Mode runMode = mode; printMessage("Run mode: " + runMode); Executors.newSingleThreadExecutor().submit(new Runnable() { @Override public void run() { if (runMode == Mode.ALL || runMode == Mode.LOCAL) { printMessage("Running Within VM Execution"); /* * LOCAL within VM execution */ WithinVmExecution lhe = new WithinVmExecution(maxJobs, maxThreads); try { Logger.getLogger(ImpaxsExecution.class.getName()).log(Level.INFO, "Sum is: " + lhe.call()); } catch (Exception ex) { Logger.getLogger(ImpaxsExecution.class.getName()).log(Level.SEVERE, null, ex); } } if (runMode == Mode.ALL || runMode == Mode.DISTRIBUTED) { printMessage("Running Distributed Host RMI Execution"); /* * Grid Engine (DRMAA API) or local host distributed RMI execution */ DistributedRmiExecution de = new DistributedRmiExecution(cfg, maxJobs); try { Logger.getLogger(ImpaxsExecution.class.getName()).log(Level.INFO, "Sum is: " + de.call()); } catch (Exception ex) { Logger.getLogger(ImpaxsExecution.class.getName()).log(Level.SEVERE, null, ex); } } System.exit(0); } }); } catch (IOException ex) { Logger.getLogger(ImpaxsExecution.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.arainfor.thermostat.daemon.HvacMonitor.java
/** * @param args The Program Arguments//from ww w. java 2 s.com */ public static void main(String[] args) throws IOException { Logger log = LoggerFactory.getLogger(HvacMonitor.class); //System.err.println(APPLICATION_NAME + " v" + APPLICATION_VERSION_MAJOR + "." + APPLICATION_VERSION_MINOR + "." + APPLICATION_VERSION_BUILD); Options options = new Options(); options.addOption("help", false, "This message isn't very helpful"); options.addOption("version", false, "Print the version number"); options.addOption("monitor", false, "Start GUI Monitor"); options.addOption("config", true, "The configuration file"); CommandLineParser parser = new GnuParser(); CommandLine cmd; try { cmd = parser.parse(options, args); if (cmd.hasOption("help")) { HelpFormatter hf = new HelpFormatter(); hf.printHelp(APPLICATION_NAME, options); return; } if (cmd.hasOption("version")) { System.out.println("The " + APPLICATION_NAME + " v" + APPLICATION_VERSION_MAJOR + "." + APPLICATION_VERSION_MINOR + "." + APPLICATION_VERSION_BUILD); } } catch (ParseException e) { e.printStackTrace(); return; } String propFileName = "thermostat.properties"; if (cmd.getOptionValue("config") != null) propFileName = cmd.getOptionValue("config"); log.info("loading...{}", propFileName); try { Properties props = new PropertiesLoader(propFileName).getProps(); // Append the system properties with our application properties props.putAll(System.getProperties()); System.setProperties(props); } catch (FileNotFoundException fnfe) { log.warn("Cannot load file:", fnfe); } new HvacMonitor().start(); }
From source file:edu.toronto.cs.xcurator.cli.CLIRunner.java
public static void main(String[] args) { Options options = setupOptions();/*ww w . ja v a 2 s . c o m*/ CommandLineParser parser = new BasicParser(); try { CommandLine line = parser.parse(options, args); if (line.hasOption('t')) { fileType = line.getOptionValue('t'); } else { fileType = XML; } if (line.hasOption('o')) { tdbDirectory = line.getOptionValue('o'); File d = new File(tdbDirectory); if (!d.exists() || !d.isDirectory()) { throw new Exception("TDB directory does not exist, please create."); } } if (line.hasOption('h')) { domain = line.getOptionValue('h'); try { URL url = new URL(domain); } catch (MalformedURLException ex) { throw new Exception("The domain name is ill-formed"); } } else { printHelpAndExit(options); } if (line.hasOption('m')) { serializeMapping = true; mappingFilename = line.getOptionValue('m'); } if (line.hasOption('d')) { dirLocation = line.getOptionValue('d'); inputStreams = new ArrayList<>(); final List<String> files = Util.getFiles(dirLocation); for (String inputfile : files) { File f = new File(inputfile); if (f.isFile() && f.exists()) { System.out.println("Adding document to mapping discoverer: " + inputfile); inputStreams.add(new FileInputStream(f)); } // If it is a URL download link for the document from SEC else if (inputfile.startsWith("http") && inputfile.contains("://")) { // Download System.out.println("Adding remote document to mapping discoverer: " + inputfile); try { URL url = new URL(inputfile); InputStream remoteDocumentStream = url.openStream(); inputStreams.add(remoteDocumentStream); } catch (MalformedURLException ex) { throw new Exception("The document URL is ill-formed: " + inputfile); } catch (IOException ex) { throw new Exception("Error in downloading remote document: " + inputfile); } } else { throw new Exception("Cannot open XBRL document: " + f.getName()); } } } if (line.hasOption('f')) { fileLocation = line.getOptionValue('f'); inputStreams = new ArrayList<>(); File f = new File(fileLocation); if (f.isFile() && f.exists()) { System.out.println("Adding document to mapping discoverer: " + fileLocation); inputStreams.add(new FileInputStream(f)); } // If it is a URL download link for the document from SEC else if (fileLocation.startsWith("http") && fileLocation.contains("://")) { // Download System.out.println("Adding remote document to mapping discoverer: " + fileLocation); try { URL url = new URL(fileLocation); InputStream remoteDocumentStream = url.openStream(); inputStreams.add(remoteDocumentStream); } catch (MalformedURLException ex) { throw new Exception("The document URL is ill-formed: " + fileLocation); } catch (IOException ex) { throw new Exception("Error in downloading remote document: " + fileLocation); } } else { throw new Exception("Cannot open XBRL document: " + f.getName()); } } setupDocumentBuilder(); RdfFactory rdfFactory = new RdfFactory(new RunConfig(domain)); List<Document> documents = new ArrayList<>(); for (InputStream inputStream : inputStreams) { Document dataDocument = null; if (fileType.equals(JSON)) { String json = IOUtils.toString(inputStream); final String xml = Util.json2xml(json); final InputStream xmlInputStream = IOUtils.toInputStream(xml); dataDocument = createDocument(xmlInputStream); } else { dataDocument = createDocument(inputStream); } documents.add(dataDocument); } if (serializeMapping) { System.out.println("Mapping file will be saved to: " + new File(mappingFilename).getAbsolutePath()); rdfFactory.createRdfs(documents, tdbDirectory, mappingFilename); } else { rdfFactory.createRdfs(documents, tdbDirectory); } } catch (Exception ex) { ex.printStackTrace(); System.err.println("Unexpected exception: " + ex.getMessage()); System.exit(1); } }
From source file:fr.liglab.jlcm.RunPLCM.java
public static void main(String[] args) throws Exception { Options options = new Options(); CommandLineParser parser = new PosixParser(); options.addOption("a", false, "Output all frequent itemsets, not only closed ones"); options.addOption("b", false, "Benchmark mode : patterns are not outputted at all (in which case OUTPUT_PATH is ignored)"); options.addOption("h", false, "Show help"); options.addOption("m", false, "Give peak memory usage after mining (instanciates a watcher thread that periodically triggers garbage collection)"); options.addOption("s", false, "Sort items in outputted patterns, in ascending order"); options.addOption("S", false, "Use arbitrary strings as item IDs (space-separated)"); options.addOption("t", true, "How many threads will be launched (defaults to your machine's processors count)"); options.addOption("v", false, "Enable verbose mode, which logs every extension of the empty pattern"); options.addOption("V", false, "Enable ultra-verbose mode, which logs every pattern extension (use with care: it may produce a LOT of output)"); try {//from w w w . j a v a 2s . co m CommandLine cmd = parser.parse(options, args); if (cmd.getArgs().length < 2 || cmd.getArgs().length > 3 || cmd.hasOption('h')) { printMan(options); } else { standalone(cmd); } } catch (ParseException e) { printMan(options); } }
From source file:javadepchecker.Main.java
/** * @param args the command line arguments *///from ww w.j av a 2 s . c om public static void main(String[] args) throws IOException { int exit = 0; try { CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption("h", "help", false, "print help"); options.addOption("i", "image", true, "image directory"); options.addOption("v", "verbose", false, "print verbose output"); CommandLine line = parser.parse(options, args); String[] files = line.getArgs(); if (line.hasOption("h") || files.length == 0) { HelpFormatter h = new HelpFormatter(); h.printHelp("java-dep-check [-i <image] <package.env>+", options); } else { image = line.getOptionValue("i", ""); for (String arg : files) { if (line.hasOption('v')) System.out.println("Checking " + arg); if (!checkPkg(new File(arg))) { exit = 1; } } } } catch (ParseException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } System.exit(exit); }
From source file:di.uniba.it.tee2.gui.TEEgui.java
/** * @param args the command line arguments *//*from ww w . java 2 s . co m*/ public static void main(String args[]) { try { CommandLine cmd = cmdParser.parse(options, args); if (cmd.hasOption("l") && cmd.hasOption("d")) { language = cmd.getOptionValue("l"); maindir = cmd.getOptionValue("d"); /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager .getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(TEEgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(TEEgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(TEEgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(TEEgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { new TEEgui().setVisible(true); } catch (IOException ex) { Logger.getLogger(TEEgui.class.getName()).log(Level.SEVERE, null, ex); } } }); } else { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp("Run GUI", options, true); } } catch (ParseException ex) { Logger.getLogger(TEEgui.class.getName()).log(Level.SEVERE, null, ex); } //</editor-fold> }