List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:net.mybox.mybox.ServerSetup.java
/** * Handle command line arguments// w ww. j av a 2s . c om * @param args */ public static void main(String[] args) { Options options = new Options(); options.addOption("a", "apphome", true, "application home directory"); options.addOption("h", "help", false, "show help screen"); options.addOption("V", "version", false, "print the Mybox version"); CommandLineParser line = new GnuParser(); CommandLine cmd = null; try { cmd = line.parse(options, args); } catch (Exception exp) { System.err.println(exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(Server.class.getName(), options); return; } if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(Server.class.getName(), options); return; } if (cmd.hasOption("V")) { Server.printMessage("version " + Common.appVersion); return; } if (cmd.hasOption("a")) { String appHomeDir = cmd.getOptionValue("a"); try { Common.updatePaths(appHomeDir); } catch (FileNotFoundException e) { Server.printErrorExit(e.getMessage()); } Server.updatePaths(); } ServerSetup setup = new ServerSetup(); }
From source file:com.microsoft.azure.management.network.samples.CreateSimpleInternetFacingLoadBalancer.java
/** * Main entry point.//from w ww . ja va2 s .c om * @param args parameters */ public static void main(String[] args) { try { //============================================================= // Authenticate final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); Azure azure = Azure.configure().withLogLevel(LogLevel.BODY.withPrettyJson(true)).authenticate(credFile) .withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
From source file:dm.reference.ReferenceTest.java
public static void main(String[] args) { ReferenceTest modelTest = null;/*w w w . j a va 2 s . c o m*/ try { modelTest = new ReferenceTest(); // modelTest.initModel(); modelTest.test(); modelTest.close(); } catch (Exception e) { log.error("Error in DmReferenceTest.main: " + e.getMessage()); modelTest.close(); } }
From source file:es.upv.grycap.opengateway.examples.AppDaemon.java
/** * Main entry point to the application.//from w w w . j a v a 2s . c om * @param args - arguments passed to the application * @throws Exception - if the application fails to start the required services */ public static void main(final String[] args) throws Exception { final AppDaemon daemon = new AppDaemon(); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { daemon.stop(); } catch (Exception e) { System.err.println( new StringBuffer("Failed to stop application: ").append(e.getMessage()).toString()); } try { daemon.destroy(); } catch (Exception e) { System.err.println( new StringBuffer("Failed to stop application: ").append(e.getMessage()).toString()); } } }); daemon.init(new DaemonContext() { @Override public DaemonController getController() { return null; } @Override public String[] getArguments() { return args; } }); daemon.start(); }
From source file:com.image32.demo.simpleapi.SimpleApiDemo.java
final public static void main(String[] args) { me = new SimpleApiDemo(); me.contentHandlers = new ContentHandler(); //load configurations try {/*from www . jav a 2s . com*/ Properties prop = new Properties(); InputStream input = SimpleApiDemo.class.getResourceAsStream("/demoConfig.properties"); // load a properties file prop.load(input); image32ApiClientId = prop.getProperty("image32ApiClientId"); image32ApiSecrect = prop.getProperty("image32ApiSecrect"); image32ApiAuthUrl = prop.getProperty("image32ApiAuthUrl"); image32ApiGetStudiesUrl = prop.getProperty("image32ApiGetStudiesUrl"); demoDataFile = prop.getProperty("demoDataFile"); input.close(); } catch (Exception ex) { logger.info("No configuration found."); System.exit(1); } // test port availability while (!checkPortAvailablity(port)) { if (port > 8090) { logger.info("Port is not available. Exiting..."); System.exit(1); } port++; } ; // run server server = new Server(port); HashSessionIdManager hashSessionIdManager = new HashSessionIdManager(); server.setSessionIdManager(hashSessionIdManager); WebAppContext homecontext = new WebAppContext(); homecontext.setContextPath("/home"); ResourceCollection resources = new ResourceCollection(new String[] { "site" }); homecontext.setBaseResource(resources); HashSessionManager manager = new HashSessionManager(); manager.setSecureCookies(true); SessionHandler sessionHandler = new SessionHandler(manager); sessionHandler.setHandler(me.contentHandlers); ContextHandler context = new ContextHandler(); context.setContextPath("/app"); context.setResourceBase("."); context.setClassLoader(Thread.currentThread().getContextClassLoader()); context.setHandler(sessionHandler); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] { homecontext, context }); server.setHandler(handlers); try { server.start(); logger.info("Server started on port " + port); logger.info("Please access this demo from browser with this url: http://localhost:" + port); if (Desktop.isDesktopSupported()) Desktop.getDesktop().browse(new URI("http://localhost:" + port + "/home")); server.join(); } catch (Exception exception) { logger.error(exception.getMessage()); } System.exit(1); }
From source file:chibi.gemmaanalysis.CorrelationAnalysisCLI.java
public static void main(String[] args) { CorrelationAnalysisCLI analysis = new CorrelationAnalysisCLI(); StopWatch watch = new StopWatch(); watch.start();/*from w w w . j av a 2 s . c o m*/ log.info("Starting Correlation Analysis"); Exception exc = analysis.doWork(args); if (exc != null) { log.error(exc.getMessage()); } log.info("Finished analysis in " + watch); }
From source file:namespace.java
public static void main(String argv[]) { int msgnum = -1; int optind;//from www . j a va2 s. c o m for (optind = 0; optind < argv.length; optind++) { if (argv[optind].equals("-T")) { protocol = argv[++optind]; } else if (argv[optind].equals("-H")) { host = argv[++optind]; } else if (argv[optind].equals("-U")) { user = argv[++optind]; } else if (argv[optind].equals("-P")) { password = argv[++optind]; } else if (argv[optind].equals("-D")) { debug = true; } else if (argv[optind].equals("-L")) { url = argv[++optind]; } else if (argv[optind].equals("-p")) { port = Integer.parseInt(argv[++optind]); } else if (argv[optind].equals("-u")) { suser = argv[++optind]; } else if (argv[optind].equals("--")) { optind++; break; } else if (argv[optind].startsWith("-")) { System.out.println("Usage: namespace [-L url] [-T protocol] [-H host] [-p port] [-U user]"); System.out.println("\t[-P password] [-u other-user] [-D]"); System.exit(1); } else { break; } } try { // Get a Properties object Properties props = System.getProperties(); // Get a Session object Session session = Session.getInstance(props, null); session.setDebug(debug); // Get a Store object Store store = null; if (url != null) { URLName urln = new URLName(url); store = session.getStore(urln); store.connect(); } else { if (protocol != null) store = session.getStore(protocol); else store = session.getStore(); // Connect if (host != null || user != null || password != null) store.connect(host, port, user, password); else store.connect(); } printFolders("Personal", store.getPersonalNamespaces()); printFolders("User \"" + suser + "\"", store.getUserNamespaces(suser)); printFolders("Shared", store.getSharedNamespaces()); store.close(); } catch (Exception ex) { System.out.println("Oops, got exception! " + ex.getMessage()); ex.printStackTrace(); } System.exit(0); }
From source file:edu.msu.cme.rdp.classifier.train.ClassifierTraineeMaker.java
/** This is the main method to create training files from raw taxonomic information. * <p>/*from w w w .java2s. c o m*/ * Usage: java ClassifierTraineeMaker tax_file rawseq.fa trainsetNo version version_modification output_directory. * See the ClassifierTraineeMaker constructor for more detail. * @param args * @throws FileNotFoundException * @throws IOException */ public static void main(String[] args) throws FileNotFoundException, IOException { String taxFile; String cnFile = null; String seqFile; int trainset_no = 1; String version = null; String modification = null; String outdir = null; try { CommandLine line = new PosixParser().parse(options, args); if (line.hasOption("t")) { taxFile = line.getOptionValue("t"); } else { throw new Exception("taxon file must be specified"); } if (line.hasOption("c")) { cnFile = line.getOptionValue("c"); } if (line.hasOption("s")) { seqFile = line.getOptionValue("s"); } else { throw new Exception("seq file must be specified"); } if (line.hasOption("n")) { try { trainset_no = Integer.parseInt(line.getOptionValue("n")); } catch (NumberFormatException ex) { throw new IllegalArgumentException("trainset_no needs to be an integer."); } } if (line.hasOption("o")) { outdir = line.getOptionValue("o"); } else { throw new Exception("output directory must be specified"); } if (line.hasOption("v")) { version = line.getOptionValue("v"); } if (line.hasOption("m")) { modification = line.getOptionValue("m"); } } catch (Exception e) { System.out.println("Command Error: " + e.getMessage()); new HelpFormatter().printHelp(120, "train", "", options, "", true); return; } ClassifierTraineeMaker maker = new ClassifierTraineeMaker(taxFile, seqFile, cnFile, trainset_no, version, modification, outdir); }
From source file:de.escidoc.core.admin.AdminMain.java
/** * Main Method, depends on args[0] which method is executed. * /*from w w w. jav a 2 s.com*/ * @param args * arguments given on commandline * @throws NoSuchMethodException * e * @throws InvocationTargetException * e * @throws IllegalAccessException * e */ public static void main(final String[] args) { int result = 20; try { AdminMain admin = new AdminMain(); // call has to have at least one argument if (args.length > 0 && !StringUtils.isEmpty(args[0])) { String methodToCall = methods.get(args[0]); if (!StringUtils.isEmpty(methodToCall)) { log.info("memory (free / max. available): " + Runtime.getRuntime().freeMemory() / 1024 / 1024 + " MB" + " / " + Runtime.getRuntime().maxMemory() / 1024 / 1024 + " MB"); Class<?>[] paramTypes = { String[].class }; Method thisMethod = admin.getClass().getDeclaredMethod(methodToCall, paramTypes); thisMethod.invoke(admin, new Object[] { args }); result = 0; } else { admin.failMessage("provided tool name: " + StringUtils.join(args, " ")); } } else { admin.failMessage(); } } catch (Exception e) { log.error(e.getMessage(), e); e.printStackTrace(); } System.exit(result); }
From source file:de.oth.keycloak.InitKeycloakServer.java
public static void main(String[] args) { CheckParams checkParams = CheckParams.create(args, System.out, InitKeycloakServer.class.getName()); if (checkParams == null) { System.exit(1);/* w w w . java2 s . com*/ } try { String server = checkParams.getServer(); String realm = checkParams.getRealm(); String user = checkParams.getUser(); String pwd = checkParams.getPwd(); String clientStr = checkParams.getClient(); String secret = checkParams.getSecret(); String initFileStr = checkParams.getInitFile(); File initFile = new File(initFileStr); if (!initFile.isFile()) { URL url = InitKeycloakServer.class.getClassLoader().getResource(initFileStr); if (url != null) { initFile = new File(url.getFile()); if (!initFile.isFile()) { log.error("init file does not exist: " + initFile); System.exit(1); } } else { log.error("init file does not exist: " + initFile); System.exit(1); } } Keycloak keycloak = (secret == null) ? Keycloak.getInstance(server, realm, user, pwd, clientStr) : Keycloak.getInstance(server, realm, user, pwd, clientStr, secret); ObjectMapper mapper = new ObjectMapper(); RealmsConfig realmsConfig = mapper.readValue(initFile, RealmsConfig.class); if (realmsConfig != null) { List<RealmConfig> realmList = realmsConfig.getRealms(); if (realmList == null || realmList.isEmpty()) { log.error("no realms config found 1"); return; } for (RealmConfig realmConf : realmList) { addRealm(keycloak, realmConf); } } else { log.error("no realms config found 2"); } } catch (Exception e) { log.error(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(); System.exit(1); } }