Example usage for java.lang Exception getLocalizedMessage

List of usage examples for java.lang Exception getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang Exception getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:com.manisha.allmybooksarepacked.service.BookParser.java

public static void main(String[] args) {
    //List<File> list = new ArrayList<>(FileUtils.listFiles(new File(mainFilePath), new String[]{"html"}, false));
    //for (final File file : list) {}

    try {//from   w w w  .  j a  va  2s  .  c o  m
        BookParser parser = new BookParser("com/manisha/allmybooksarepacked/data/book1.html");
        System.out.println("JSON : " + JSONUtils.objectToJSON(parser.getBook()));
        //System.out.println("BOOK : "+parser.getBook().toString());
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("ERROR: " + ex.getLocalizedMessage());
    }
}

From source file:com.qperior.GSAOneBoxProvider.QPOneBoxProviderServletTest.java

/**
 * //  w ww .  java2  s . c om
 * @param args 
 */
public static void main(String[] args) {

    String uri = "http://localhost:8080/GSAOneBoxProvider/QPOneBoxProviderServlet?apiMaj=1&apiMin=1&authType=none&lang=en&oneboxName=test&query=test";

    try {
        QPOneBoxProviderServletTest test = new QPOneBoxProviderServletTest();
        String actual = test.callHttpGet(uri);
    } catch (Exception exc) {
        fail("Exception in DoGet: " + exc.getLocalizedMessage());
    }
}

From source file:com.engineering.ses.spell.clientstubj.cmdclient.CommandClient.java

/***************************************************************************
 * Main program/*from  w w  w  .ja  va2s  . c  om*/
 **************************************************************************/
public static void main(String[] args) {
    CommandClient client = new CommandClient();

    try {
        client.mainLoop(args);
    } catch (Exception ex) {
        System.err.println("ERROR: " + ex.getLocalizedMessage());
    } finally {
        client.stop();
    }
}

From source file:com.cfs.util.AESCriptografia.java

public static void main(String[] args) {
    AESCriptografia aes = new AESCriptografia();
    String msg = "Teste4";
    String key = "8TScvUZRTmS8V6hd/cZt/A==";

    try {//from w w w.  ja  va 2 s.  co m
        System.out.println("                 AES - " + aes.testeCifrar(msg, key));
        String teste = "AES/ECB/PKCS5PADDING";
        Cipher cipher = Cipher.getInstance(teste);
        cipher.init(Cipher.ENCRYPT_MODE, aes.gerarChave(key));
        byte[] original = msg.getBytes();
        byte[] cifrada = cipher.doFinal(original);
        byte[] retorno = Base64.encodeBase64(cifrada);

        System.out.println(teste + " - " + new String(retorno));
    } catch (Exception e) {
        System.out.println(Utilities.getInstance().getLineNumber() + e.getLocalizedMessage());
    }
}

From source file:com.aspose.email.examples.outlook.pst.SplitAndMergePSTFile.java

public static void main(String[] args) {

    //Following examples will not run with trail version. You have to purchase Aspose License.
    try {/*from ww  w. jav  a  2  s  .  c  om*/
        Utils.applyALicense();
    } catch (Exception e) {
        System.out.println("License file is missing: " + e.getLocalizedMessage());
    }

    //Splitting PST into Multiple PST files
    splitPSTIntoMultiplePSTFiles();

    //Merging of Multiple PSTs into a Single PST
    mergeMultiplePSTsIntoASinglePST();

    //Merging Folders from another PST
    mergeFoldersFromAnotherPST();

    //Splitting PST based on Specified Criterion
    splitPSTBasedOnDefinedCriterion();
}

From source file:com.ebay.jetstream.application.JetstreamApplication.java

/**
 * Every Jetstream application shares a common main(). It creates the instance of the application, configures command
 * line options, parses the command line based on the options, starts the application based on the resulting
 * configuration, and then runs the application.
 * /*from  w w  w.j av  a 2  s .c o  m*/
 * @param args
 *          command line arguments
 */
public static void main(String[] args) throws Exception {
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
    JetstreamApplication ta = null;
    try {
        ta = getInstance();
        // Allow JetstreamApplication option handling methods to be protected
        final JetstreamApplication optionHandler = ta;
        new CliOptions(new CliOptionHandler() {
            public Options addOptions(Options options) {
                return optionHandler.addOptions(options);
            }

            public void parseOptions(CommandLine line) {
                optionHandler.parseOptions(line);
            }
        }, args);

        if (System.getenv("COS") == null)
            System.setProperty("COS", "Dev");

        ta.init();
    } catch (Exception e) {
        LOGGER.error("Failed to start Application" + e.getLocalizedMessage());
        System.err.println("Failed to start application: " + e);
        e.printStackTrace(System.err);
        System.exit(1);
    }
    ta.run(); // this is the container's event loop
}

From source file:com.norconex.collector.http.HttpCollector.java

/**
 * Invokes the HTTP Collector from the command line.  
 * @param args Invoke it once without any arguments to get a 
 *    list of command-line options./*from  ww  w  .  j a v  a 2  s. c o  m*/
 */
public static void main(String[] args) {
    CommandLine cmd = parseCommandLineArguments(args);
    String action = cmd.getOptionValue(ARG_ACTION);
    File configFile = new File(cmd.getOptionValue(ARG_CONFIG));
    File varFile = null;
    if (cmd.hasOption(ARG_VARIABLES)) {
        varFile = new File(cmd.getOptionValue(ARG_VARIABLES));
    }

    try {
        HttpCollector conn = new HttpCollector(configFile, varFile);
        if (ARG_ACTION_START.equalsIgnoreCase(action)) {
            conn.crawl(false);
        } else if (ARG_ACTION_RESUME.equalsIgnoreCase(action)) {
            conn.crawl(true);
        } else if (ARG_ACTION_STOP.equalsIgnoreCase(action)) {
            conn.stop();
        }
    } catch (Exception e) {
        File errorFile = new File("./error-" + System.currentTimeMillis() + ".log");
        System.err.println("\n\nAn ERROR occured:\n\n" + e.getLocalizedMessage());
        System.err.println(
                "\n\nDetails of the error has been stored at: " + errorFile.getAbsolutePath() + "\n\n");
        try {
            PrintWriter w = new PrintWriter(errorFile);
            e.printStackTrace(w);
            w.flush();
            w.close();
        } catch (FileNotFoundException e1) {
            throw new HttpCollectorException("Cannot write error file.", e1);
        }
    }
}

From source file:com.flagleader.builder.FlagLeader.java

public static void main(String[] paramArrayOfString) {
    Shell localShell = new Shell(16777216);
    localShell.setLocation(new Point(300, 200));
    localShell.setLayout(new FillLayout());
    Composite localComposite = new Composite(localShell, 0);
    localComposite.setLayout(new FillLayout());
    Label localLabel = new Label(localComposite, 0);
    Image localImage = ImageDescriptor
            .createFromURL(localShell.getClass().getClassLoader().getResource("icons/start.jpg")).createImage();
    localLabel.setImage(localImage);// w  w  w.  ja v a  2 s .c  om
    localShell.setSize(400, 300);
    localShell.setText("Visual Rules Solution");
    localShell.open();
    Init.a();
    String str = null;
    if (BuilderConfig.getInstance().isLoadDefault())
        str = RuleRepository.DEFAULTEXT;
    if (paramArrayOfString.length > 0)
        str = "";
    for (int i = 0; i < paramArrayOfString.length; i++)
        str = str + paramArrayOfString[i] + " ";
    Logger localLogger = Logger.getLogger("ruleengine");
    Object localObject;
    try {
        new File(SystemUtils.USER_HOME + File.separator + ".visualrules" + File.separator + "logs").mkdirs();
        FileHandler localFileHandler = new FileHandler(SystemUtils.USER_HOME + File.separator + ".visualrules"
                + File.separator + "logs" + File.separator + "logfile%u.%g.txt", 0, 10);
        localFileHandler.setFormatter(new com.flagleader.server.c());
        localFileHandler.setLevel(Level.ALL);
        Logger.getLogger("flagleader").addHandler(localFileHandler);
        localLogger.addHandler(localFileHandler);
    } catch (Exception localException1) {
        if (!b) {
            localObject = new ConsoleHandler();
            ((ConsoleHandler) localObject).setFormatter(new com.flagleader.server.c());
            ((ConsoleHandler) localObject).setLevel(Level.ALL);
            Logger.getLogger("flagleader").addHandler((Handler) localObject);
            localLogger.addHandler((Handler) localObject);
        }
    }
    if (!BuilderManager.checkLicense()) {
        localImage.dispose();
        localShell.dispose();
        return;
    }
    Property.getInstance().setEngineImplement("com.flagleader.engine.impl.SingleRuleEngineFactory");
    FlagLeader localFlagLeader = new FlagLeader();
    Property.getInstance().setUpdateInternateTime(0L);
    localFlagLeader.setBlockOnOpen(true);
    localFlagLeader.builderManager = new BuilderManager(localFlagLeader);
    if ((com.flagleader.manager.d.c.a("needLogin", false)) || (BuilderConfig.getInstance().isFirstLogin()))
        try {
            localObject = localFlagLeader.builderManager.getUserServer();
            if ((localObject == null) || (((String) localObject).length() == 0)
                    || (localFlagLeader.builderManager.getUserType() == 0)
                    || (localFlagLeader.builderManager.getUserid() == 0)) {
                localImage.dispose();
                localShell.dispose();
                return;
            }
        } catch (Exception localException2) {
            MessageDialog.openError(null, "",
                    ResourceTools.getMessage("loginserver.error") + localException2.getLocalizedMessage());
            localImage.dispose();
            localShell.dispose();
            return;
        }
    if ((str != null) && (new File(str).exists()))
        localFlagLeader.builderManager.getRulesManager().a(new File(str));
    localFlagLeader.initWindow();
    if (new File(SystemUtils.JAVA_IO_TMPDIR, "engine.jar").exists())
        new File(SystemUtils.JAVA_IO_TMPDIR, "engine.jar").delete();
    if (new File(SystemUtils.JAVA_IO_TMPDIR, "export.jar").exists())
        new File(SystemUtils.JAVA_IO_TMPDIR, "export.jar").delete();
    if (BuilderConfig.getInstance().isAutosave())
        new com.flagleader.builder.d.c(localFlagLeader.builderManager).b();
    if (BuilderConfig.getInstance().isAutoCheckVersion())
        new a(localFlagLeader.builderManager).b();
    new e().b();
    localImage.dispose();
    localShell.dispose();
    localFlagLeader.open();
    BuilderManager localBuilderManager = localFlagLeader.builderManager;
    localFlagLeader.getShell().addShellListener(new d(localBuilderManager));
}

From source file:de.flashpixx.rrd_antlr4.CMain.java

/**
 * main/*from  www. j a v a  2 s  .c om*/
 *
 * @param p_args command-line arguments
 * @throws IOException on any io error
 */
public static void main(final String[] p_args) throws IOException {
    // --- define CLI options ---
    final Options l_clioptions = new Options();
    l_clioptions.addOption("help", false, CCommon.languagestring(CMain.class, "help"));
    l_clioptions.addOption("output", true, CCommon.languagestring(CMain.class, "output", DEFAULTOUTPUT));
    l_clioptions.addOption("imports", true, CCommon.languagestring(CMain.class, "import"));
    l_clioptions.addOption("excludes", true, CCommon.languagestring(CMain.class, "exclude"));
    l_clioptions.addOption("grammar", true, CCommon.languagestring(CMain.class, "grammar"));
    l_clioptions.addOption("language", true, CCommon.languagestring(CMain.class, "language"));
    l_clioptions.addOption("docclean", true, CCommon.languagestring(CMain.class, "documentationclean"));
    l_clioptions.addOption("templates", true, CCommon.languagestring(CMain.class, "template",
            Arrays.asList(ETemplate.values()), DEFAULTTEMPLATE));

    final CommandLine l_cli;
    try {
        l_cli = new DefaultParser().parse(l_clioptions, p_args);
    } catch (final Exception l_exception) {
        System.err
                .println(CCommon.languagestring(CMain.class, "parseerror", l_exception.getLocalizedMessage()));
        System.exit(-1);
        return;
    }

    // --- process CLI arguments and push configuration ---
    if (l_cli.hasOption("help")) {
        final HelpFormatter l_formatter = new HelpFormatter();
        l_formatter.printHelp(
                new java.io.File(CMain.class.getProtectionDomain().getCodeSource().getLocation().getPath())
                        .getName(),
                l_clioptions);
        System.exit(0);
    }

    if (!l_cli.hasOption("grammar")) {
        System.err.println(CCommon.languagestring(CMain.class, "grammarnotset"));
        System.exit(-1);
    }

    final Tuple5<File, Set<ETemplate>, Set<File>, Set<String>, Set<String>> l_initdata = CMain.initialize(
            l_cli.getOptionValue("language"),

            l_cli.hasOption("output") ? l_cli.getOptionValue("output") : DEFAULTOUTPUT,

            l_cli.hasOption("templates") ? l_cli.getOptionValue("templates").split(",")
                    : new String[] { DEFAULTTEMPLATE },

            l_cli.getOptionValue("imports", "").split(","),

            l_cli.getOptionValue("excludes", "").split(","),

            l_cli.getOptionValue("docclean", "").split(","));

    // --- run generator ---
    final IGenerator l_generator = new CStandalone(l_initdata.v1(), l_initdata.v3(), l_initdata.v5(),
            l_initdata.v2());

    if (Arrays.stream(l_cli.getOptionValue("grammar").split(","))
            .flatMap(i -> CMain.filelist(new File(i.trim()), l_initdata.v3(), l_initdata.v4()))
            .map(i -> l_generator.generate(i).hasError()).findFirst().isPresent())
        System.exit(-1);

    l_generator.finish();
}

From source file:io.janusproject.Boot.java

/** Main function that is parsing the command line and launching
 * the first agent./*from w w w  . j  av  a  2 s . com*/
 *
 * @param args - command line arguments
 * @see #startJanus(Class, Class, Object...)
 */
public static void main(String[] args) {
    try {
        List<URL> propertyFiles = new ArrayList<>();
        Object[] freeArgs = parseCommandLine(args, propertyFiles);
        if (JanusConfig.getSystemPropertyAsBoolean(JanusConfig.JANUS_LOGO_SHOW_NAME,
                JanusConfig.JANUS_LOGO_SHOW)) {
            showJanusLogo();
        }
        if (freeArgs.length == 0) {
            showError(Locale.getString("NO_AGENT_QUALIFIED_NAME"), //$NON-NLS-1$
                    null);
        }
        String agentToLaunch = freeArgs[0].toString();
        freeArgs = Arrays.copyOfRange(freeArgs, 1, freeArgs.length, String[].class);
        // Load the agent class
        Class<? extends Agent> agent = loadAgentClass(agentToLaunch);
        assert (agent != null);
        // Load property files
        Properties systemProperties = System.getProperties();
        for (URL url : propertyFiles) {
            try (InputStream stream = url.openStream()) {
                systemProperties.load(stream);
            }
        }
        // Set the boot agent classname
        System.setProperty(JanusConfig.BOOT_AGENT, agent.getCanonicalName());

        startJanus(null, (Class<? extends Agent>) agent, freeArgs);
    } catch (Exception e) {
        showError(Locale.getString("LAUNCHING_ERROR", //$NON-NLS-1$
                e.getLocalizedMessage()), e);
        return;
    }
}