Example usage for java.util Locale setDefault

List of usage examples for java.util Locale setDefault

Introduction

In this page you can find the example usage for java.util Locale setDefault.

Prototype

public static synchronized void setDefault(Locale newLocale) 

Source Link

Document

Sets the default locale for this instance of the Java Virtual Machine.

Usage

From source file:eu.mrbussy.pdfsplitter.Application.java

/**
 * Start the main program./*from   w w w .j a va 2s  .  c  om*/
 * 
 * @param args
 *            - Arguments passed on to the program
 */
public static void main(String[] args) {

    // Read configurations
    try {
        String configDirname = FilenameUtils.concat(System.getProperty("user.home"),
                String.format(".%1$s%2$s", NAME, IOUtils.DIR_SEPARATOR));
        String filename = FilenameUtils.concat(configDirname, CONFIGURATION_FILE);

        // Check to see if the directory exists and the file can be created/opened
        File configDir = new File(configDirname);
        if (!configDir.exists())
            configDir.mkdir();

        // Check to see if the file exists. If not create it
        File file = new File(filename);
        if (!file.exists()) {
            file.createNewFile();
        }
        Configuration = new PropertiesConfiguration(file);
        // Automatically store the settings that change
        Configuration.setAutoSave(true);

    } catch (ConfigurationException | IOException ex) {
        // Unable to read the file. Probably because it does not exist --> create it.
        ex.printStackTrace();
    }

    // Set locale to a configured language
    Locale.setDefault(
            new Locale(Configuration.getString("language", "nl"), Configuration.getString("country", "NL")));

    // Start by parsing the command line
    ParseCommandline(args);

    // Display the help if required and leave the app
    if (arguments.hasOption("h")) {
        showHelp();
    }

    // Display the app version and leave the app.
    if (arguments.hasOption("v")) {
        showVersion();
    }

    // Not command line so start the app GUI
    if (!arguments.hasOption("c")) {
        try {
            // Change the look and feel
            UIManager.setLookAndFeel(
                    Configuration.getString("LookAndFeel", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"));
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    (new MainWindow()).setVisible(true);
                }
            });
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException e) {
            // Something terrible happened so show the  help
            showHelp();
        }

    }

}

From source file:de.cenote.jasperstarter.App.java

/**
 * @param args the command line arguments
 */// w w  w  .  j a v a 2  s.co m
public static void main(String[] args) {
    Config config = new Config();
    App app = new App();
    // create the command line parser
    ArgumentParser parser = app.createArgumentParser(config);
    if (args.length == 0) {
        System.out.println(parser.formatUsage());
        System.out.println("type: jasperstarter -h to get help");
        System.exit(0);
    }
    try {
        app.parseArgumentParser(args, parser, config);
    } catch (ArgumentParserException ex) {
        parser.handleError(ex);
        System.exit(1);
    }
    if (config.isVerbose()) {
        System.out.print("Command line:");
        for (String arg : args) {
            System.out.print(" " + arg);
        }
        // @todo: this makes sense only if Config.toString() is overwitten
        //            System.out.print("\n");
        //            System.out.println(config);
    }

    // @todo: main() will not be executed in tests...
    // setting locale if given
    if (config.hasLocale()) {
        Locale.setDefault(config.getLocale());
    }

    try {
        switch (Command.getCommand(config.getCommand())) {
        case COMPILE:
        case CP:
            app.compile(config);
            break;
        case PROCESS:
        case PR:
            app.processReport(config);
            break;
        case LIST_PRINTERS:
        case PRINTERS:
        case LPR:
            app.listPrinters();
            break;
        case LIST_PARAMETERS:
        case PARAMS:
        case LPA:
            App.listReportParams(config, new File(config.getInput()).getAbsoluteFile());
            break;
        }
    } catch (IllegalArgumentException ex) {
        System.err.println(ex.getMessage());
        System.exit(1);
    } catch (InterruptedException ex) {
        System.err.println(ex.getMessage());
        System.exit(1);
    } catch (JRException ex) {
        System.err.println(ex.getMessage());
        System.exit(1);
    }
}

From source file:com.cc.apptroy.baksmali.main.java

/**
 * Run!//  www.  ja v a 2 s  .  co  m
 */
public static void main(String[] args) throws IOException {
    Locale locale = new Locale("en", "US");
    Locale.setDefault(locale);

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine;

    try {
        commandLine = parser.parse(options, args);
    } catch (ParseException ex) {
        usage();
        return;
    }

    baksmaliOptions options = new baksmaliOptions();

    boolean disassemble = true;
    boolean doDump = false;
    String dumpFileName = null;
    boolean setBootClassPath = false;

    String[] remainingArgs = commandLine.getArgs();
    Option[] clOptions = commandLine.getOptions();

    for (int i = 0; i < clOptions.length; i++) {
        Option option = clOptions[i];
        String opt = option.getOpt();

        switch (opt.charAt(0)) {
        case 'v':
            version();
            return;
        case '?':
            while (++i < clOptions.length) {
                if (clOptions[i].getOpt().charAt(0) == '?') {
                    usage(true);
                    return;
                }
            }
            usage(false);
            return;
        case 'o':
            options.outputDirectory = commandLine.getOptionValue("o");
            break;
        case 'p':
            options.noParameterRegisters = true;
            break;
        case 'l':
            options.useLocalsDirective = true;
            break;
        case 's':
            options.useSequentialLabels = true;
            break;
        case 'b':
            options.outputDebugInfo = false;
            break;
        case 'd':
            options.bootClassPathDirs.add(option.getValue());
            break;
        case 'f':
            options.addCodeOffsets = true;
            break;
        case 'r':
            String[] values = commandLine.getOptionValues('r');
            int registerInfo = 0;

            if (values == null || values.length == 0) {
                registerInfo = baksmaliOptions.ARGS | baksmaliOptions.DEST;
            } else {
                for (String value : values) {
                    if (value.equalsIgnoreCase("ALL")) {
                        registerInfo |= baksmaliOptions.ALL;
                    } else if (value.equalsIgnoreCase("ALLPRE")) {
                        registerInfo |= baksmaliOptions.ALLPRE;
                    } else if (value.equalsIgnoreCase("ALLPOST")) {
                        registerInfo |= baksmaliOptions.ALLPOST;
                    } else if (value.equalsIgnoreCase("ARGS")) {
                        registerInfo |= baksmaliOptions.ARGS;
                    } else if (value.equalsIgnoreCase("DEST")) {
                        registerInfo |= baksmaliOptions.DEST;
                    } else if (value.equalsIgnoreCase("MERGE")) {
                        registerInfo |= baksmaliOptions.MERGE;
                    } else if (value.equalsIgnoreCase("FULLMERGE")) {
                        registerInfo |= baksmaliOptions.FULLMERGE;
                    } else {
                        usage();
                        return;
                    }
                }

                if ((registerInfo & baksmaliOptions.FULLMERGE) != 0) {
                    registerInfo &= ~baksmaliOptions.MERGE;
                }
            }
            options.registerInfo = registerInfo;
            break;
        case 'c':
            String bcp = commandLine.getOptionValue("c");
            if (bcp != null && bcp.charAt(0) == ':') {
                options.addExtraClassPath(bcp);
            } else {
                setBootClassPath = true;
                options.setBootClassPath(bcp);
            }
            break;
        case 'x':
            options.deodex = true;
            break;
        case 'X':
            options.experimental = true;
            break;
        case 'm':
            options.noAccessorComments = true;
            break;
        case 'a':
            options.apiLevel = Integer.parseInt(commandLine.getOptionValue("a"));
            break;
        case 'j':
            options.jobs = Integer.parseInt(commandLine.getOptionValue("j"));
            break;
        case 'i':
            String rif = commandLine.getOptionValue("i");
            options.setResourceIdFiles(rif);
            break;
        case 't':
            options.useImplicitReferences = true;
            break;
        case 'e':
            options.dexEntry = commandLine.getOptionValue("e");
            break;
        case 'k':
            options.checkPackagePrivateAccess = true;
            break;
        case 'N':
            disassemble = false;
            break;
        case 'D':
            doDump = true;
            dumpFileName = commandLine.getOptionValue("D");
            break;
        case 'I':
            options.ignoreErrors = true;
            break;
        case 'T':
            options.customInlineDefinitions = new File(commandLine.getOptionValue("T"));
            break;
        default:
            assert false;
        }
    }

    if (remainingArgs.length != 1) {
        usage();
        return;
    }

    if (options.jobs <= 0) {
        options.jobs = Runtime.getRuntime().availableProcessors();
        if (options.jobs > 6) {
            options.jobs = 6;
        }
    }

    String inputDexFileName = remainingArgs[0];

    File dexFileFile = new File(inputDexFileName);
    if (!dexFileFile.exists()) {
        System.err.println("Can't find the file " + inputDexFileName);
        System.exit(1);
    }

    //Read in and parse the dex file
    DexBackedDexFile dexFile = DexFileFactory.loadDexFile(dexFileFile, options.dexEntry, options.apiLevel,
            options.experimental);

    if (dexFile.isOdexFile()) {
        if (!options.deodex) {
            System.err.println("Warning: You are disassembling an odex file without deodexing it. You");
            System.err.println("won't be able to re-assemble the results unless you deodex it with the -x");
            System.err.println("option");
            options.allowOdex = true;
        }
    } else {
        options.deodex = false;
    }

    if (!setBootClassPath && (options.deodex || options.registerInfo != 0)) {
        if (dexFile instanceof DexBackedOdexFile) {
            options.bootClassPathEntries = ((DexBackedOdexFile) dexFile).getDependencies();
        } else {
            options.bootClassPathEntries = getDefaultBootClassPathForApi(options.apiLevel,
                    options.experimental);
        }
    }

    if (options.customInlineDefinitions == null && dexFile instanceof DexBackedOdexFile) {
        options.inlineResolver = InlineMethodResolver
                .createInlineMethodResolver(((DexBackedOdexFile) dexFile).getOdexVersion());
    }

    boolean errorOccurred = false;
    if (disassemble) {
        errorOccurred = !baksmali.disassembleDexFile(dexFile, options);
    }

    if (doDump) {
        if (dumpFileName == null) {
            dumpFileName = commandLine.getOptionValue(inputDexFileName + ".dump");
        }
        dump.dump(dexFile, dumpFileName, options.apiLevel, options.experimental);
    }

    if (errorOccurred) {
        System.exit(1);
    }
}

From source file:org.jf.baksmali.main.java

/**
 * Run!//from w  ww  .j a va  2 s. c o  m
 */
public static void main(String[] args) throws IOException {
    Locale locale = new Locale("en", "US");
    Locale.setDefault(locale);

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine;

    try {
        commandLine = parser.parse(options, args);
    } catch (ParseException ex) {
        usage();
        return;
    }

    baksmaliOptions options = new baksmaliOptions();

    boolean disassemble = true;
    boolean doDump = false;
    String dumpFileName = null;
    boolean setBootClassPath = false;

    String[] remainingArgs = commandLine.getArgs();
    Option[] clOptions = commandLine.getOptions();

    for (int i = 0; i < clOptions.length; i++) {
        Option option = clOptions[i];
        String opt = option.getOpt();

        switch (opt.charAt(0)) {
        case 'v':
            version();
            return;
        case '?':
            while (++i < clOptions.length) {
                if (clOptions[i].getOpt().charAt(0) == '?') {
                    usage(true);
                    return;
                }
            }
            usage(false);
            return;
        case 'o':
            options.outputDirectory = commandLine.getOptionValue("o");
            break;
        case 'p':
            options.noParameterRegisters = true;
            break;
        case 'l':
            options.useLocalsDirective = true;
            break;
        case 's':
            options.useSequentialLabels = true;
            break;
        case 'b':
            options.outputDebugInfo = false;
            break;
        case 'd':
            options.bootClassPathDirs.add(option.getValue());
            break;
        case 'f':
            options.addCodeOffsets = true;
            break;
        case 'r':
            String[] values = commandLine.getOptionValues('r');
            int registerInfo = 0;

            if (values == null || values.length == 0) {
                registerInfo = baksmaliOptions.ARGS | baksmaliOptions.DEST;
            } else {
                for (String value : values) {
                    if (value.equalsIgnoreCase("ALL")) {
                        registerInfo |= baksmaliOptions.ALL;
                    } else if (value.equalsIgnoreCase("ALLPRE")) {
                        registerInfo |= baksmaliOptions.ALLPRE;
                    } else if (value.equalsIgnoreCase("ALLPOST")) {
                        registerInfo |= baksmaliOptions.ALLPOST;
                    } else if (value.equalsIgnoreCase("ARGS")) {
                        registerInfo |= baksmaliOptions.ARGS;
                    } else if (value.equalsIgnoreCase("DEST")) {
                        registerInfo |= baksmaliOptions.DEST;
                    } else if (value.equalsIgnoreCase("MERGE")) {
                        registerInfo |= baksmaliOptions.MERGE;
                    } else if (value.equalsIgnoreCase("FULLMERGE")) {
                        registerInfo |= baksmaliOptions.FULLMERGE;
                    } else {
                        usage();
                        return;
                    }
                }

                if ((registerInfo & baksmaliOptions.FULLMERGE) != 0) {
                    registerInfo &= ~baksmaliOptions.MERGE;
                }
            }
            options.registerInfo = registerInfo;
            break;
        case 'c':
            String bcp = commandLine.getOptionValue("c");
            if (bcp != null && bcp.charAt(0) == ':') {
                options.addExtraClassPath(bcp);
            } else {
                setBootClassPath = true;
                options.setBootClassPath(bcp);
            }
            break;
        case 'x':
            options.deodex = true;
            break;
        case 'm':
            options.noAccessorComments = true;
            break;
        case 'a':
            options.apiLevel = Integer.parseInt(commandLine.getOptionValue("a"));
            break;
        case 'j':
            options.jobs = Integer.parseInt(commandLine.getOptionValue("j"));
            break;
        case 'i':
            String rif = commandLine.getOptionValue("i");
            options.setResourceIdFiles(rif);
            break;
        case 'N':
            disassemble = false;
            break;
        case 'D':
            doDump = true;
            dumpFileName = commandLine.getOptionValue("D");
            break;
        case 'I':
            options.ignoreErrors = true;
            break;
        case 'T':
            options.inlineResolver = new CustomInlineMethodResolver(options.classPath,
                    new File(commandLine.getOptionValue("T")));
            break;
        default:
            assert false;
        }
    }

    if (remainingArgs.length != 1) {
        usage();
        return;
    }

    if (options.jobs <= 0) {
        options.jobs = Runtime.getRuntime().availableProcessors();
        if (options.jobs > 6) {
            options.jobs = 6;
        }
    }

    if (options.apiLevel >= 17) {
        options.checkPackagePrivateAccess = true;
    }

    String inputDexFileName = remainingArgs[0];

    File dexFileFile = new File(inputDexFileName);
    if (!dexFileFile.exists()) {
        System.err.println("Can't find the file " + inputDexFileName);
        System.exit(1);
    }

    //Read in and parse the dex file
    DexBackedDexFile dexFile = DexFileFactory.loadDexFile(dexFileFile, options.apiLevel);

    if (dexFile.isOdexFile()) {
        if (!options.deodex) {
            System.err.println("Warning: You are disassembling an odex file without deodexing it. You");
            System.err.println("won't be able to re-assemble the results unless you deodex it with the -x");
            System.err.println("option");
            options.allowOdex = true;
        }
    } else {
        options.deodex = false;
    }

    if (!setBootClassPath && (options.deodex || options.registerInfo != 0)) {
        if (dexFile instanceof DexBackedOdexFile) {
            options.bootClassPathEntries = ((DexBackedOdexFile) dexFile).getDependencies();
        } else {
            options.bootClassPathEntries = getDefaultBootClassPathForApi(options.apiLevel);
        }
    }

    if (options.inlineResolver == null && dexFile instanceof DexBackedOdexFile) {
        options.inlineResolver = InlineMethodResolver
                .createInlineMethodResolver(((DexBackedOdexFile) dexFile).getOdexVersion());
    }

    boolean errorOccurred = false;
    if (disassemble) {
        errorOccurred = !baksmali.disassembleDexFile(dexFile, options);
    }

    if (doDump) {
        if (dumpFileName == null) {
            dumpFileName = commandLine.getOptionValue(inputDexFileName + ".dump");
        }
        dump.dump(dexFile, dumpFileName, options.apiLevel);
    }

    if (errorOccurred) {
        System.exit(1);
    }
}

From source file:org.jf.smali.main.java

/**
 * Run!/*from w w  w  . j  a v  a 2s  . co m*/
 */
public static void main(String[] args) {
    Locale locale = new Locale("en", "US");
    Locale.setDefault(locale);

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine;

    try {
        commandLine = parser.parse(options, args);
    } catch (ParseException ex) {
        usage();
        return;
    }

    int jobs = -1;
    boolean allowOdex = false;
    boolean verboseErrors = false;
    boolean printTokens = false;

    int apiLevel = 15;

    String outputDexFile = "out.dex";

    String[] remainingArgs = commandLine.getArgs();

    Option[] options = commandLine.getOptions();

    for (int i = 0; i < options.length; i++) {
        Option option = options[i];
        String opt = option.getOpt();

        switch (opt.charAt(0)) {
        case 'v':
            version();
            return;
        case '?':
            while (++i < options.length) {
                if (options[i].getOpt().charAt(0) == '?') {
                    usage(true);
                    return;
                }
            }
            usage(false);
            return;
        case 'o':
            outputDexFile = commandLine.getOptionValue("o");
            break;
        case 'x':
            allowOdex = true;
            break;
        case 'a':
            apiLevel = Integer.parseInt(commandLine.getOptionValue("a"));
            break;
        case 'j':
            jobs = Integer.parseInt(commandLine.getOptionValue("j"));
            break;
        case 'V':
            verboseErrors = true;
            break;
        case 'T':
            printTokens = true;
            break;
        default:
            assert false;
        }
    }

    if (remainingArgs.length == 0) {
        usage();
        return;
    }

    try {
        LinkedHashSet<File> filesToProcess = new LinkedHashSet<File>();

        for (String arg : remainingArgs) {
            File argFile = new File(arg);

            if (!argFile.exists()) {
                throw new RuntimeException("Cannot find file or directory \"" + arg + "\"");
            }

            if (argFile.isDirectory()) {
                getSmaliFilesInDir(argFile, filesToProcess);
            } else if (argFile.isFile()) {
                filesToProcess.add(argFile);
            }
        }

        if (jobs <= 0) {
            jobs = Runtime.getRuntime().availableProcessors();
            if (jobs > 6) {
                jobs = 6;
            }
        }

        boolean errors = false;

        final DexBuilder dexBuilder = DexBuilder.makeDexBuilder(apiLevel);
        ExecutorService executor = Executors.newFixedThreadPool(jobs);
        List<Future<Boolean>> tasks = Lists.newArrayList();

        final boolean finalVerboseErrors = verboseErrors;
        final boolean finalPrintTokens = printTokens;
        final boolean finalAllowOdex = allowOdex;
        final int finalApiLevel = apiLevel;
        for (final File file : filesToProcess) {
            tasks.add(executor.submit(new Callable<Boolean>() {
                @Override
                public Boolean call() throws Exception {
                    return assembleSmaliFile(file, dexBuilder, finalVerboseErrors, finalPrintTokens,
                            finalAllowOdex, finalApiLevel);
                }
            }));
        }

        for (Future<Boolean> task : tasks) {
            while (true) {
                try {
                    if (!task.get()) {
                        errors = true;
                    }
                } catch (InterruptedException ex) {
                    continue;
                }
                break;
            }
        }

        executor.shutdown();

        if (errors) {
            System.exit(1);
        }

        dexBuilder.writeTo(new FileDataStore(new File(outputDexFile)));
    } catch (RuntimeException ex) {
        System.err.println("\nUNEXPECTED TOP-LEVEL EXCEPTION:");
        ex.printStackTrace();
        System.exit(2);
    } catch (Throwable ex) {
        System.err.println("\nUNEXPECTED TOP-LEVEL ERROR:");
        ex.printStackTrace();
        System.exit(3);
    }
}

From source file:at.ac.univie.isc.asio.Asio.java

public static void main(String[] args) {
    Launcher.currentProcess().daemonize();
    Locale.setDefault(Locale.ENGLISH);
    application().run(args);
}

From source file:org.cc.smali.main.java

/**
 * Run!//www  .  j a  v a  2  s.  c  o  m
 */
public static void main(String[] args) {
    Locale locale = new Locale("en", "US");
    Locale.setDefault(locale);

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine;

    try {
        commandLine = parser.parse(options, args);
    } catch (ParseException ex) {
        usage();
        return;
    }

    int jobs = -1;
    boolean allowOdex = false;
    boolean verboseErrors = false;
    boolean printTokens = false;
    boolean experimental = false;

    int apiLevel = 15;

    String outputDexFile = "out.dex";

    String[] remainingArgs = commandLine.getArgs();

    Option[] options = commandLine.getOptions();

    for (int i = 0; i < options.length; i++) {
        Option option = options[i];
        String opt = option.getOpt();

        switch (opt.charAt(0)) {
        case 'v':
            version();
            return;
        case '?':
            while (++i < options.length) {
                if (options[i].getOpt().charAt(0) == '?') {
                    usage(true);
                    return;
                }
            }
            usage(false);
            return;
        case 'o':
            outputDexFile = commandLine.getOptionValue("o");
            break;
        case 'x':
            allowOdex = true;
            break;
        case 'X':
            experimental = true;
            break;
        case 'a':
            apiLevel = Integer.parseInt(commandLine.getOptionValue("a"));
            break;
        case 'j':
            jobs = Integer.parseInt(commandLine.getOptionValue("j"));
            break;
        case 'V':
            verboseErrors = true;
            break;
        case 'T':
            printTokens = true;
            break;
        default:
            assert false;
        }
    }

    if (remainingArgs.length == 0) {
        usage();
        return;
    }

    try {
        LinkedHashSet<File> filesToProcess = new LinkedHashSet<File>();

        for (String arg : remainingArgs) {
            File argFile = new File(arg);

            if (!argFile.exists()) {
                throw new RuntimeException("Cannot find file or directory \"" + arg + "\"");
            }

            if (argFile.isDirectory()) {
                getSmaliFilesInDir(argFile, filesToProcess);
            } else if (argFile.isFile()) {
                filesToProcess.add(argFile);
            }
        }

        if (jobs <= 0) {
            jobs = Runtime.getRuntime().availableProcessors();
            if (jobs > 6) {
                jobs = 6;
            }
        }

        boolean errors = false;

        final DexBuilder dexBuilder = DexBuilder.makeDexBuilder(apiLevel);
        ExecutorService executor = Executors.newFixedThreadPool(jobs);
        List<Future<Boolean>> tasks = Lists.newArrayList();

        final boolean finalVerboseErrors = verboseErrors;
        final boolean finalPrintTokens = printTokens;
        final boolean finalAllowOdex = allowOdex;
        final int finalApiLevel = apiLevel;
        final boolean finalExperimental = experimental;
        for (final File file : filesToProcess) {
            tasks.add(executor.submit(new Callable<Boolean>() {
                @Override
                public Boolean call() throws Exception {
                    return assembleSmaliFile(file, dexBuilder, finalVerboseErrors, finalPrintTokens,
                            finalAllowOdex, finalApiLevel, finalExperimental);
                }
            }));
        }

        for (Future<Boolean> task : tasks) {
            while (true) {
                try {
                    if (!task.get()) {
                        errors = true;
                    }
                } catch (InterruptedException ex) {
                    continue;
                }
                break;
            }
        }

        executor.shutdown();

        if (errors) {
            System.exit(1);
        }

        dexBuilder.writeTo(new FileDataStore(new File(outputDexFile)));
    } catch (RuntimeException ex) {
        System.err.println("\nUNEXPECTED TOP-LEVEL EXCEPTION:");
        ex.printStackTrace();
        System.exit(2);
    } catch (Throwable ex) {
        System.err.println("\nUNEXPECTED TOP-LEVEL ERROR:");
        ex.printStackTrace();
        System.exit(3);
    }
}

From source file:com.projity.pm.graphic.gantt.Main.java

public static void main(String[] args) {
    System.setProperty("com.apple.mrj.application.apple.menu.about.name",
            Environment.getStandAlone() ? "OpenProj" : "Project-ON-Demand");
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    Locale.setDefault(ConfigurationFile.getLocale());
    HashMap opts = ApplicationStartupFactory.extractOpts(args);
    String osName = System.getProperty("os.name").toLowerCase();
    if (osName.startsWith("linux")) {
        String javaExec = ConfigurationFile.getRunProperty("JAVA_EXE");
        //check jvm
        String javaVersion = System.getProperty("java.version");
        if (Environment.compareJavaVersion(javaVersion, "1.5") < 0) {
            String message = Messages.getStringWithParam("Text.badJavaVersion", javaVersion);
            if (javaExec != null && javaExec.length() > 0)
                message += "\n" + Messages.getStringWithParam("Text.javaExecutable",
                        new Object[] { javaExec, "JAVA_EXE", "$HOME/.openproj/run.conf" });
            if (!opts.containsKey("silentlyFail"))
                JOptionPane.showMessageDialog(null, message, Messages.getContextString("Title.ProjityError"),
                        JOptionPane.ERROR_MESSAGE);
            System.exit(64);/*from   w w  w  .j a  v  a 2 s.  c  om*/
        }
        String javaVendor = System.getProperty("java.vendor");
        if (javaVendor == null || !(javaVendor.startsWith("Sun") || javaVendor.startsWith("IBM"))) {
            String message = Messages.getStringWithParam("Text.badJavaVendor", javaVendor);
            if (javaExec != null && javaExec.length() > 0)
                message += "\n" + Messages.getStringWithParam("Text.javaExecutable",
                        new Object[] { javaExec, "JAVA_EXE", "$HOME/.openproj/run.conf" });
            if (!opts.containsKey("silentlyFail"))
                JOptionPane.showMessageDialog(null, message, Messages.getContextString("Title.ProjityError"),
                        JOptionPane.ERROR_MESSAGE);
            System.exit(64);
        }
    }

    boolean newLook = false;
    //      HashMap opts = ApplicationStartupFactory.extractOpts(args); // allow setting menu look on command line - primarily for testing or webstart args
    log.info(opts);
    //      newLook = opts.get("menu") == null;

    Environment.setNewLook(newLook);
    //      if (!Environment.isNewLaf()) {
    //         try {
    //            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    //         } catch (Exception e) {
    //         }
    //      }
    ApplicationStartupFactory startupFactory = new ApplicationStartupFactory(opts); //put before to initialize standalone flag
    mainFrame = new MainFrame(Messages.getContextString("Text.ApplicationTitle"), null, null);
    boolean doWelcome = true; // to do see if project param exists in args
    startupFactory.instanceFromNewSession(mainFrame, doWelcome);
}

From source file:com.unispezi.cpanelremotebackup.CPanelRemoteBackup.java

/**
 * main/*from   w ww .  ja  v  a2 s  . c o  m*/
 * @param args arguments
 */
public static void main(String[] args) {

    Locale.setDefault(Locale.ENGLISH); // We don't support I18n yet, but args4j does. Set args4j to English.
    CPanelRemoteBackup backup = new CPanelRemoteBackup();

    CmdLineParser parser = new CmdLineParser(backup);
    try {
        parser.parseArgument(args);
        backup.run();
    } catch (CmdLineException e) {
        // handling of wrong arguments
        System.err.println(
                "CPanelRemoteBackup - Triggers full backup on remote CPanel server, then downloads it");
        System.err.println(e.getMessage());
        System.err.println("Usage: java -jar CPanelRemoteBackup.jar hostname [outdir]");
        parser.printUsage(System.err);
    }
}

From source file:jeplus.Main.java

/**
 * @param args the command line arguments
 *//*from  w w  w. j a  v  a 2  s .  c  o m*/
public static void main(String[] args) {
    //        if (REDIRECT_ERR) {
    //            try {
    //                // Redirect err
    //                System.setErr(new PrintStream(new FileOutputStream("jeplus.err")));
    //            } catch (FileNotFoundException ex) {
    //                //Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    //                ex.printStackTrace();
    //            }
    //        }

    try {
        // Set cross-platform Java L&F (also called "Metal")
        //            UIManager.setLookAndFeel(
        //                UIManager.getCrossPlatformLookAndFeelClassName());
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        //                if ("Nimbus".equals(info.getName())) {
        //                    UIManager.setLookAndFeel(info.getClassName());
        //                    break;
        //                }
        //            }
    } catch (UnsupportedLookAndFeelException e) {
        System.err.println("Unsupported Look-And-Feel Option. Reverting to the default UI.");
    } catch (ClassNotFoundException e) {
        System.err.println("Specified Look-And-Feel class cannot be found. Reverting to the default UI.");
    } catch (InstantiationException e) {
        System.err.println("Fialed to instantiate the specified Look-And-Feel. Reverting to the default UI.");
    } catch (IllegalAccessException e) {
        System.err.println("Cannot access the specified Look-And-Feel. Reverting to the default UI.");
    }

    // Set locale to UK
    Locale.setDefault(Locale.UK);
    // Set line end to DOS style
    System.setProperty("line.separator", "\r\n");
    // System.setProperty("file.separator", "/");  // seemed to have no effect

    // create the parser
    CommandLineParser parser = new GnuParser();
    Options options = new Main().getCommandLineOptions(null);
    CommandLine commandline = null;
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(80);
    try {
        // parse the command line arguments
        commandline = parser.parse(options, args);
        if (commandline.hasOption("help")) {
            // automatically generate the help statement
            formatter.printHelp("java -Xmx1000m -jar jEPlus.jar [OPTIONS]", options);
            System.exit(-1);
        }
        // Set log4j configuration
        if (commandline.hasOption("log")) {
            PropertyConfigurator.configure(commandline.getOptionValue("log"));
        } else {
            PropertyConfigurator.configure("log4j.cfg");
        }
    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
        // automatically generate the help statement
        formatter.printHelp("java -Xmx1000m -jar jEPlus.jar [OPTIONS]", options);
        System.exit(-1);
    }

    // Call main fuction with commandline
    new Main().mainFunction(commandline);
}