List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:com.esri.geoevent.clusterSimulator.GeoeventClusterSimulator.java
public static void main(String[] args) { Options options = MyOptions.createOptions(); CommandLineParser parser = new BasicParser(); CommandLine cmd = null;/*from w w w . ja va 2s. c o m*/ try { cmd = parser.parse(options, args); } catch (ParseException e1) { MyOptions.printUsageAndExit(); } try { ClientServerMode mode = getMode(cmd.getOptionValue('m', "CLIENT")); Simulator simulator = null; int batchSize = 1; if (cmd.hasOption('b')) { try { batchSize = Integer.parseInt(cmd.getOptionValue('b')); if (batchSize < 1) { batchSize = 1; System.err.println("Error : " + cmd.getOptionValue('b') + " is not a valid value for the batch size. Using \'1\' instead."); } } catch (NumberFormatException ex) { System.err.println( "Error : " + cmd.getOptionValue('b') + " is not a valid value for the batch size."); } } boolean trustAllSSLCerts = cmd.hasOption('t'); int period = Integer.parseInt(cmd.getOptionValue('d', "1000")); switch (mode) { case CLIENT: simulator = getSimulator(cmd.getOptionValue('f'), true, cmd.hasOption('l'), batchSize, period); serverAdminClient = new ServerAdminClient(cmd.getOptionValue('h'), cmd.getOptionValue('u', "siteadmin"), cmd.getOptionValue('p', "password"), simulator, (trustAllSSLCerts) ? new AcceptAlwaysCertChecker() : new CommandLineCertChecker()); simulator.start(); break; case SERVER: simulator = getSimulator(cmd.getOptionValue('f'), false, cmd.hasOption('l'), batchSize, period); tcpServer = new TCPServer(simulator); simulator.start(); break; default: break; } } catch (Exception e) { System.err.println("Error : " + e.getMessage()); System.exit(1); } }
From source file:com.aestel.chemistry.openEye.fp.apps.SDFFPSphereExclusion.java
public static void main(String... args) throws IOException { // create command line Options object Options options = new Options(); Option opt = new Option("in", true, "input file [.sdf,...]"); opt.setRequired(true);//from www .j a v a 2s . com options.addOption(opt); opt = new Option("out", true, "output file oe-supported"); opt.setRequired(false); options.addOption(opt); opt = new Option("ref", true, "refrence file to be loaded before starting"); opt.setRequired(false); options.addOption(opt); opt = new Option("fpTag", true, "field containing fingerpPrint"); opt.setRequired(true); options.addOption(opt); opt = new Option("maxTanimoto", false, "If given the modified maxTanimoto will be used = common/(2*Max(na,nb)-common)."); opt.setRequired(false); options.addOption(opt); opt = new Option("radius", true, "radius of exclusion sphere, exclude anything with similarity >= radius."); opt.setRequired(true); options.addOption(opt); opt = new Option("printSphereMatchCount", false, "check and print membership of candidates not " + " only to the first centroid which has sim >= radius but to all centroids" + " found up to that input. This will output a candidate multiple times." + " Implies checkSpheresInOrder."); options.addOption(opt); opt = new Option("checkSpheresInOrder", false, "For each candiate: compare to centroids from first to last (default is last to first)"); options.addOption(opt); opt = new Option("printAll", false, "print all molecule, check includeIdx tag"); options.addOption(opt); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); if (cmd.hasOption("d")) { System.err.println("Start debugger and press return:"); new BufferedReader(new InputStreamReader(System.in)).readLine(); } // the only reason not to match centroids in reverse order id if // a non-centroid is to be assigned to multiple centroids boolean printSphereMatchCount = cmd.hasOption("printSphereMatchCount"); boolean reverseMatch = !cmd.hasOption("checkSpheresInOrder") && !printSphereMatchCount; boolean printAll = cmd.hasOption("printAll") || printSphereMatchCount; boolean doMaxTanimoto = cmd.hasOption("maxTanimoto"); String fpTag = cmd.getOptionValue("fpTag"); double radius = Double.parseDouble(cmd.getOptionValue("radius")); String inFile = cmd.getOptionValue("in"); String outFile = cmd.getOptionValue("out"); String refFile = cmd.getOptionValue("ref"); SimComparatorFactory<OEMolBase, FPComparator, FPComparator> compFact = new FPComparatorFact(doMaxTanimoto, fpTag); SphereExclusion<FPComparator, FPComparator> alg = new SphereExclusion<FPComparator, FPComparator>(compFact, refFile, outFile, radius, reverseMatch, printSphereMatchCount, printAll); alg.run(inFile); alg.close(); }
From source file:com.aestel.chemistry.openEye.fp.FPDictionarySorter.java
public static void main(String... args) throws IOException { long start = System.currentTimeMillis(); int iCounter = 0; int fpCounter = 0; // create command line Options object Options options = new Options(); Option opt = new Option("i", true, "input file [.ism,.sdf,...]"); opt.setRequired(true);/*w w w.j a va 2 s .co m*/ options.addOption(opt); opt = new Option("fpType", true, "fingerPrintType: maccs|linear7|linear7*4"); opt.setRequired(true); options.addOption(opt); opt = new Option("sampleFract", true, "fraction of input molecules to use (Default=1)"); opt.setRequired(false); options.addOption(opt); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); if (cmd.hasOption("d")) { System.err.println("Start debugger and press return:"); new BufferedReader(new InputStreamReader(System.in)).readLine(); } if (args.length != 0) { exitWithHelp(options); } String type = cmd.getOptionValue("fpType"); boolean updateDictionaryFile = false; boolean hashUnknownFrag = false; Fingerprinter fprinter = Fingerprinter.createFingerprinter(type, updateDictionaryFile, hashUnknownFrag); OEMolBase mol = new OEGraphMol(); String inFile = cmd.getOptionValue("i"); oemolistream ifs = new oemolistream(inFile); double fract = 2D; String tmp = cmd.getOptionValue("sampleFract"); if (tmp != null) fract = Double.parseDouble(tmp); Random rnd = new Random(); LearningStrcutureCodeMapper mapper = (LearningStrcutureCodeMapper) fprinter.getMapper(); int dictSize = mapper.getMaxIdx() + 1; int[] freq = new int[dictSize]; while (oechem.OEReadMolecule(ifs, mol)) { iCounter++; if (rnd.nextDouble() < fract) { fpCounter++; Fingerprint fp = fprinter.getFingerprint(mol); for (int bit : fp.getBits()) freq[bit]++; } if (iCounter % 100 == 0) System.err.print("."); if (iCounter % 4000 == 0) { System.err.printf(" %d %d %dsec\n", iCounter, fpCounter, (System.currentTimeMillis() - start) / 1000); } } System.err.printf("FPDictionarySorter: Read %d structures calculated %d fprints in %d sec\n", iCounter, fpCounter, (System.currentTimeMillis() - start) / 1000); mapper.reSortDictionary(freq); mapper.writeDictionary(); fprinter.close(); }
From source file:de.uni_potsdam.hpi.bpt.promnicat.importer.ModelImporter.java
/** * Usage: <code>'Path to config' Collection PATH [PATH2 [PATH3] ...]]</code> * </br></br>/*from w w w . j a v a 2 s. co m*/ * <code>Path to config</code> is a path in file system to the configuration file being used * for import. It can be given relative to the PromniCAT folder.</br> * If an empty string is provided, the default file 'PromniCAT/configuration.properties' is used.</br></br> * <code>Collection</code> is the process model collection and can be one of * 'BPMN', 'NPB', 'SAP_RM' or 'AOK' </br></br> * <code>PATH</code> is a path in file system to a directory containing the models that should be imported. */ public static void main(String[] args) { // wrong number of parameter? if (args.length < 3) { printHelpMessage(); return; } try { //read configuration file IPersistenceApi persistenceApi = new ConfigurationParser(args[0]) .getDbInstance(Constants.DATABASE_TYPES.ORIENT_DB); //import models // BPMAI model? if (args[1].toUpperCase().equals(Constants.ORIGIN_BPMAI)) { startImport(new BpmaiImporter(persistenceApi), args); return; } // NPB model? if (args[1].toUpperCase().equals(Constants.ORIGIN_NPB)) { startImport(new NPBImporter(persistenceApi), args); return; } // SAP_RM model? if (args[1].toUpperCase().equals(Constants.ORIGIN_SAP_RM)) { startImport(new SapReferenceModelImporter(persistenceApi), args); return; } // AOK model? if (args[1].toUpperCase().equals(Constants.ORIGIN_AOK)) { startImport(new AokModelImporter(persistenceApi), args); return; } // wrong argument value printHelpMessage(); throw new IllegalArgumentException(WRONG_USAGE_MESSAGE); } catch (Exception e) { logger.severe(e.getMessage()); String stackTraceString = ""; for (StackTraceElement ste : e.getStackTrace()) { stackTraceString = stackTraceString.concat(ste.toString() + "\n"); } logger.severe(stackTraceString); } }
From source file:pwr.lab5.Window.java
public static void main(String[] args) { try {/*from w w w. ja va 2s. c o m*/ JFrame frame = new JFrame(); Window win = new Window(); // frame.add(pane); frame.add(win); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); frame.pack(); JButton tab[] = new JButton[] { win.jButton1, win.jButton2, win.jButton3, win.jButton4, win.jButton5 }; for (JButton jb : tab) { jb.addActionListener(win); } } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage()); } }
From source file:com.lxf.spider.client.ClientWithRequestFuture.java
public static void main(String[] args) throws Exception { // the simplest way to create a HttpAsyncClientWithFuture HttpClient httpclient = HttpClientBuilder.create().setMaxConnPerRoute(5).setMaxConnTotal(5).build(); ExecutorService execService = Executors.newFixedThreadPool(5); FutureRequestExecutionService requestExecService = new FutureRequestExecutionService(httpclient, execService);//from ww w .ja v a2 s . c om try { // Because things are asynchronous, you must provide a ResponseHandler ResponseHandler<Boolean> handler = new ResponseHandler<Boolean>() { public Boolean handleResponse(HttpResponse response) throws ClientProtocolException, IOException { // simply return true if the status was OK return response.getStatusLine().getStatusCode() == 200; } }; // Simple request ... HttpGet request1 = new HttpGet("http://google.com"); HttpRequestFutureTask<Boolean> futureTask1 = requestExecService.execute(request1, HttpClientContext.create(), handler); Boolean wasItOk1 = futureTask1.get(); System.out.println("It was ok? " + wasItOk1); // Cancel a request try { HttpGet request2 = new HttpGet("http://google.com"); HttpRequestFutureTask<Boolean> futureTask2 = requestExecService.execute(request2, HttpClientContext.create(), handler); futureTask2.cancel(true); Boolean wasItOk2 = futureTask2.get(); System.out.println("It was cancelled so it should never print this: " + wasItOk2); } catch (CancellationException e) { System.out.println("We cancelled it, so this is expected"); } // Request with a timeout HttpGet request3 = new HttpGet("http://google.com"); HttpRequestFutureTask<Boolean> futureTask3 = requestExecService.execute(request3, HttpClientContext.create(), handler); Boolean wasItOk3 = futureTask3.get(10, TimeUnit.SECONDS); System.out.println("It was ok? " + wasItOk3); FutureCallback<Boolean> callback = new FutureCallback<Boolean>() { public void completed(Boolean result) { System.out.println("completed with " + result); } public void failed(Exception ex) { System.out.println("failed with " + ex.getMessage()); } public void cancelled() { System.out.println("cancelled"); } }; // Simple request with a callback HttpGet request4 = new HttpGet("http://google.com"); // using a null HttpContext here since it is optional // the callback will be called when the task completes, fails, or is cancelled HttpRequestFutureTask<Boolean> futureTask4 = requestExecService.execute(request4, HttpClientContext.create(), handler, callback); Boolean wasItOk4 = futureTask4.get(10, TimeUnit.SECONDS); System.out.println("It was ok? " + wasItOk4); } finally { requestExecService.close(); } }
From source file:com.discursive.jccook.bean.BeanUtilExample.java
public static void main(String[] pArgs) { if (pArgs.length > 0 && pArgs[0] != null) { propName = pArgs[0];/*from www. ja v a2s . c o m*/ } System.out.println("Getting Property: " + propName); List books = createBooks(); Iterator i = books.iterator(); while (i.hasNext()) { Book book = (Book) i.next(); Object propVal = null; try { propVal = PropertyUtils.getProperty(book, propName); } catch (Exception e) { System.out.println("Error getting property: " + propName + ", from book: " + book.getName() + ", exception: " + e.getMessage()); } System.out.println("Property Value: " + propVal); } }
From source file:org.ktunaxa.referral.shapereader.ShapeImportRunner.java
/** * Upload shape files from the command prompt. * /*from w w w .j a v a 2s .co m*/ * @param args * no arguments used. */ public static void main(String[] args) { try { new ShapeImportRunner().importShape(args.length > 0 ? args[0] : null); } catch (Exception e) { System.err.println("ERROR: " + e.getMessage()); // NOSONAR System.err.println("Aborting..."); // NOSONAR System.exit(1); // NOSONAR } System.out.println("Done!"); }
From source file:com.bt.aloha.testing.SimpleSipStackLogEnhancer.java
/** * @param args//from w w w . jav a 2 s . c o m */ public static void main(String[] args) { if (args.length != 2) { System.err.println("Must specify exactly 2 args: source file and target file"); System.exit(1); } SimpleSipStackLogEnhancer logEnhancer = new SimpleSipStackLogEnhancer(args[0], args[1]); try { System.err.println(new Date().toString() + " Log Enhancer starts...."); System.out.println("Allocating colours to calls..."); logEnhancer.allocateColoursToDialogs(); System.out.println("Building HTML..."); logEnhancer.buildReportHtml(); System.out.println("Done."); System.err.println(new Date().toString() + " ...Log Enhancer ends"); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); } }
From source file:boa.datagen.BoaGenerator.java
public static void main(final String[] args) throws IOException { final Options options = new Options(); BoaGenerator.addOptions(options);//from w w w. jav a 2 s. c o m final CommandLine cl; try { cl = new PosixParser().parse(options, args); BoaGenerator.handleCmdOptions(cl, options, args); } catch (final Exception e) { printHelp(options, e.getMessage()); return; } /* * 1. if user provides local json files 2. if user provides username and * password in both the cases json files are going to be available */ if (jsonAvailable) { CacheGithubJSON.main(args); try { SeqRepoImporter.main(args); } catch (final InterruptedException e) { e.printStackTrace(); } // SeqProjectCombiner.main(args); // SeqSort.main(args); // SeqSortMerge.main(args); try { MapFileGen.main(args); } catch (final Exception e) { e.printStackTrace(); } } else { // when user provides local repo and does not have json files final File output = new File(DefaultProperties.GH_JSON_CACHE_PATH); if (!output.exists()) output.mkdirs(); LocalGitSequenceGenerator.localGitSequenceGenerate(DefaultProperties.GH_GIT_PATH, DefaultProperties.GH_JSON_CACHE_PATH); try { MapFileGen.main(args); } catch (final Exception e) { e.printStackTrace(); } } if (cl.hasOption("cache")) clear(true); else clear(false); }