List of usage examples for java.util Locale setDefault
public static synchronized void setDefault(Locale newLocale)
From source file:org.pmedv.blackboard.app.BlackBoard.java
@SuppressWarnings("unused") public static void main(String[] args) throws Exception { String fileName = null;/* ww w. j a v a 2 s. c o m*/ if (args.length == 1 && args[0] != null) { if (!args[0].startsWith("-")) { fileName = args[0]; } } InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream("application.properties"); Properties p = new Properties(); p.load(is); if (!p.getProperty("language").equalsIgnoreCase("default")) { Locale.setDefault(new Locale(p.getProperty("language"))); } log.info("Initalizing application"); BlackBoard app = new BlackBoard(fileName); }
From source file:com.floreantpos.main.Main.java
/** * @param args/* www.ja v a 2 s .c o m*/ * @throws Exception */ public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption(DEVELOPMENT_MODE, true, "State if this is developmentMode"); //$NON-NLS-1$ CommandLineParser parser = new BasicParser(); CommandLine commandLine = parser.parse(options, args); String optionValue = commandLine.getOptionValue(DEVELOPMENT_MODE); Locale defaultLocale = TerminalConfig.getDefaultLocale(); if (defaultLocale != null) { Locale.setDefault(defaultLocale); } Application application = Application.getInstance(); if (optionValue != null) { application.setDevelopmentMode(Boolean.valueOf(optionValue)); } application.start(); }
From source file:org.joverseer.ui.JOverseerJIDEClient.java
/** * Main routine for the simple sample application. * //from w w w. jav a2 s . co m * @param args */ @SuppressWarnings("unused") public static void main(String[] args) throws Exception { try { System.setProperty("java.util.Arrays.useLegacyMergeSort", "true"); // until sorting bug fixed. cmdLineArgs = args; _logger.info("JOverseer Client starting up"); if (args.length > 0) { if (args[0].equals("-L")) { Locale.setDefault(new Locale(args[1])); } } com.jidesoft.utils.Lm.verifyLicense("Marios Skounakis", "JOverseer", "L1R4Nx7vEp0nMbsoaHdH7nkRrx5F.dO"); LookAndFeelFactory.installDefaultLookAndFeelAndExtension(); // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); // LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); // In order to launch the platform, we have to construct an // application context that defines the beans (services) and // wiring. This is pretty much straight Spring. // // Part of this configuration will indicate the initial page to be // displayed. String rootContextDirectoryClassPath = "/ctx"; // The startup context defines elements that should be available // quickly such as a splash screen image. String startupContextPath = rootContextDirectoryClassPath + "/richclient-startup-context.xml"; String richclientApplicationContextPath = rootContextDirectoryClassPath + "/richclient-application-context.xml"; // The ApplicationLauncher is responsible for loading the contexts, // presenting the splash screen, initializing the Application // singleton instance, creating the application window to display // the initial page. // Application.instance(). new ApplicationLauncher(STARTUP_CONTEXT, new String[] { APPLICATION_CONTEXT, PAGE_CONTEXT, PREFERENCES_CONTEXT }); } catch (Exception e) { System.out.println(e); throw e; // System.exit(1); } }
From source file:org.nmrml.reader.Reader.java
public static void main(String[] args) { Options options = new Options(); options.addOption("h", "help", false, "prints the help content"); options.addOption("v", "version", false, "prints the version"); options.addOption(OptionBuilder.withArgName("nmrML file").hasArg().isRequired() .withDescription("input nmrML file").withLongOpt("input").create("i")); options.addOption(OptionBuilder.withArgName("output text file").hasArg() .withDescription("extract FID data onto a text file").withLongOpt("fid").create()); options.addOption(OptionBuilder.withArgName("output text file").hasArg() .withDescription("extract Real Spectrum data onto a text file").withLongOpt("real-spectrum") .create());//from ww w . ja va2 s . com try { Locale.setDefault(new Locale("en", "US")); String current_dir = new java.io.File(".").getCanonicalPath(); CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); String inputFile = cmd.getOptionValue("i"); /* Read nmrML file */ NmrMLReader nmrML = new NmrMLReader(new File(inputFile), cmd.hasOption("fid"), cmd.hasOption("real-spectrum")); System.out.println("nmrML version = " + nmrML.getNmrMLVersion()); /* ACQUISITION PARAMETERS */ System.out.println("ACQU NumberOfSteadyStateScans = " + nmrML.acq.getNumberOfSteadyStateScans()); System.out.println("ACQU NumberOfScans = " + nmrML.acq.getNumberOfScans()); System.out.println(String.format("ACQU RelaxationDelay (%s) = %f", nmrML.acq.getRelaxationDelayUnitName(), nmrML.acq.getRelaxationDelay())); System.out.println(String.format("ACQU SampleAcquisitionTemperature (%s) = %f", nmrML.acq.getTemperatureUnitName(), nmrML.acq.getTemperature())); System.out.println(String.format("ACQU SweepWidth (%s) = %f", nmrML.acq.getSweepWidthUnitName(), nmrML.acq.getSpectralWidthHz())); System.out.println(String.format("ACQU IrradiationFrequency (%s) = %f", nmrML.acq.getTransmiterFreqUnitName(), nmrML.acq.getTransmiterFreq())); System.out.println(String.format("ACQU EffectiveExcitationField (%s) = %f", nmrML.acq.getSpectralFrequencyUnitName(), nmrML.acq.getSpectralFrequency())); // ... /* Read FID data */ if (cmd.hasOption("fid")) { String fileFile = cmd.getOptionValue("fid"); BufferedWriter outfid = new BufferedWriter(new FileWriter(fileFile)); for (int i = 0; i < nmrML.fidData.getNumberOfDataPoints(); i++) { for (int j = 0; j < nmrML.fidData.getYdimension(); j++) { if (j > 0) { outfid.write("\t"); } outfid.write(String.format("%f", nmrML.fidData.getYvalues()[j][i])); } outfid.newLine(); } outfid.close(); System.out.println( String.format("ACQU FID Number of DataPoints = %d", nmrML.fidData.getNumberOfDataPoints())); System.out.println(String.format("ACQU FID Dimension = %d", nmrML.fidData.getYdimension())); } /* PROCESSING PARAMETERS */ if (nmrML.proc != null) { if (cmd.hasOption("real-spectrum")) { System.out.println(String.format("PROC Real Spectrum Number of DataPoints = %d", nmrML.realSpectrum.getNumberOfDataPoints())); System.out.println( String.format("PROC Real Spectrum Dimension = %d", nmrML.realSpectrum.getYdimension())); System.out.println(String.format("PROC PPM Start (ppm) = %f", nmrML.proc.getMaxPpm())); System.out.println(String.format("PROC PPM End (ppm) = %f", nmrML.proc.getMinPpm())); // ... String spectrumFile = cmd.getOptionValue("real-spectrum"); BufferedWriter out1r = new BufferedWriter(new FileWriter(spectrumFile)); for (int i = 0; i < nmrML.realSpectrum.getNumberOfDataPoints(); i++) { out1r.write(String.format("%f\t", nmrML.realSpectrum.getXvalues()[i])); for (int j = 0; j < nmrML.realSpectrum.getYdimension(); j++) { if (j > 0) { out1r.write("\t"); } out1r.write(String.format("%f", nmrML.realSpectrum.getYvalues()[j][i])); } out1r.newLine(); } out1r.close(); } } } catch (MissingOptionException e) { boolean help = false; boolean version = false; try { Options helpOptions = new Options(); helpOptions.addOption("h", "help", false, "prints the help content"); helpOptions.addOption("v", "version", false, "prints the version"); CommandLineParser parser = new PosixParser(); CommandLine line = parser.parse(helpOptions, args); if (line.hasOption("h")) help = true; if (line.hasOption("v")) version = true; } catch (Exception ex) { } if (!help && !version) System.err.println(e.getMessage()); if (help) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("reader", options); } if (version) { System.out.println("nmrML Reader version = " + Version); } System.exit(1); } catch (MissingArgumentException e) { System.err.println(e.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("App", options); System.exit(1); } catch (ParseException e) { System.err.println("Error while parsing the command line: " + e.getMessage()); System.exit(1); } catch (NullPointerException e) { System.err.println("Error while parsing the XML file: " + e.getMessage()); System.exit(1); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.movsim.MovsimCoreMainWithExperiments.java
/** * The main method./*from w w w . j a va 2s . c om*/ * * @param args * the command line arguments * @throws SAXException * @throws JAXBException * @throws ParserConfigurationException */ public static void main(String[] args) throws JAXBException, SAXException { int numExperiment = 0; Arrays.sort(DO_EXPERIMENT); for (String experimentName : NAME_EXPERIMENT) { numExperiment++; if (Arrays.binarySearch(DO_EXPERIMENT, experimentName) < 0) { for (int i = 1; i <= NUM_REPETITIONS; i++) { String[] argsExp = new String[] { "-f", PATH_EXPERIMENT + "\\" + experimentName }; Locale.setDefault(Locale.US); // final ProjectMetaData projectMetaData = ProjectMetaData.getInstance(); // parse the command line, putting the results into projectMetaData Logger.initializeLogger(); MovsimCommandLine.parse(argsExp); if (!ProjectMetaData.getInstance().hasProjectName()) { System.err.println("no xml simulation configuration file provided."); System.exit(-1); } LogFileAppender.initialize(ProjectMetaData.getInstance()); final Simulator simulator = new Simulator(); simulator.initialize(); simulator.runToCompletion(); String prefixFile = null; Collection<File> lstFile = FileUtils.listFiles(new File("./"), new String[] { "csv" }, false); File fRoute; File fRouteDir = new File(PATH_EXPERIMENT + "\\" + numExperiment + "\\" + i); boolean isFirstFile = false; for (File file : lstFile) { if (file.getName().startsWith(FilenameUtils.getBaseName(experimentName) + ".tt.route") || file.getName().startsWith( FilenameUtils.getBaseName(experimentName) + ".consumption.route")) { if (file.getName() .startsWith(FilenameUtils.getBaseName(experimentName) + ".tt.route")) { prefixFile = ".tt.route"; } else { prefixFile = ".consumption.route"; } fRoute = new File(PATH_EXPERIMENT + "\\" + numExperiment + "\\" + i + "\\" + FilenameUtils.getBaseName(experimentName) + prefixFile + ".csv"); if (!fRoute.exists()) { try { isFirstFile = true; FileUtils.forceMkdir(fRouteDir); fRoute.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } try { appendFiles(file, fRoute, isFirstFile); isFirstFile = false; } catch (IOException e) { e.printStackTrace(); } try { FileUtils.moveFile(file, new File(PATH_EXPERIMENT + "\\" + numExperiment + "\\" + i + "\\src\\" + file.getName())); } catch (IOException e) { e.printStackTrace(); } } } } } } }
From source file:RedPenRunner.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("h", "help", false, "help"); options.addOption("v", "version", false, "print the version information and exit"); OptionBuilder.withLongOpt("port"); OptionBuilder.withDescription("port number"); OptionBuilder.hasArg();//from www .j ava2s.c om OptionBuilder.withArgName("PORT"); options.addOption(OptionBuilder.create("p")); OptionBuilder.withLongOpt("key"); OptionBuilder.withDescription("stop key"); OptionBuilder.hasArg(); OptionBuilder.withArgName("STOP_KEY"); options.addOption(OptionBuilder.create("k")); OptionBuilder.withLongOpt("conf"); OptionBuilder.withDescription("configuration file"); OptionBuilder.hasArg(); OptionBuilder.withArgName("CONFIG_FILE"); options.addOption(OptionBuilder.create("c")); OptionBuilder.withLongOpt("lang"); OptionBuilder.withDescription("Language of error messages"); OptionBuilder.hasArg(); OptionBuilder.withArgName("LANGUAGE"); options.addOption(OptionBuilder.create("L")); CommandLineParser parser = new BasicParser(); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); } catch (Exception e) { printHelp(options); System.exit(-1); } int portNum = 8080; String language = "en"; if (commandLine.hasOption("h")) { printHelp(options); System.exit(0); } if (commandLine.hasOption("v")) { System.out.println(RedPen.VERSION); System.exit(0); } if (commandLine.hasOption("p")) { portNum = Integer.parseInt(commandLine.getOptionValue("p")); } if (commandLine.hasOption("L")) { language = commandLine.getOptionValue("L"); } if (isPortTaken(portNum)) { System.err.println("port is taken..."); System.exit(1); } // set language if (language.equals("ja")) { Locale.setDefault(new Locale("ja", "JA")); } else { Locale.setDefault(new Locale("en", "EN")); } final String contextPath = System.getProperty("redpen.home", "/"); Server server = new Server(portNum); ProtectionDomain domain = RedPenRunner.class.getProtectionDomain(); URL location = domain.getCodeSource().getLocation(); HandlerList handlerList = new HandlerList(); if (commandLine.hasOption("key")) { // Add Shutdown handler only when STOP_KEY is specified ShutdownHandler shutdownHandler = new ShutdownHandler(commandLine.getOptionValue("key")); handlerList.addHandler(shutdownHandler); } WebAppContext webapp = new WebAppContext(); webapp.setContextPath(contextPath); if (location.toExternalForm().endsWith("redpen-server/target/classes/")) { // use redpen-server/target/redpen-server instead, because target/classes doesn't contain web resources. webapp.setWar(location.toExternalForm() + "../redpen-server/"); } else { webapp.setWar(location.toExternalForm()); } if (commandLine.hasOption("c")) { webapp.setInitParameter("redpen.conf.path", commandLine.getOptionValue("c")); } handlerList.addHandler(webapp); server.setHandler(handlerList); server.start(); server.join(); }
From source file:es.tunelator.Start.java
/** * Bootstraps the application, creates and shows the user interface * @param args/*from w ww. j a va 2 s. co m*/ */ public static void main(String[] args) { MainFrame frame = null; try { // LogFactory.getFactory().setAttribute(LogFactoryImpl.LOG_PROPERTY, // Log4JLogger.class.getName()); // PropertyConfigurator.configure(Start.class.getClassLoader(). // getResource("log4j.properties")); // Set log level as configured at the application parameters Logger.setLogThreshold(AppParameters.getParams().getProperty("log.threshold", AppParameters.LOG_ERROR)); // If the language of the default locale is not supported revert to english if (!isLocaleSupported()) { Locale.setDefault(new Locale("en", "", "")); } else { Locale.setDefault(new Locale(Locale.getDefault().getLanguage(), "", "")); } // Log application startup Logger.logInfo(Start.class, Resourcer.getString(null, "log.info.startup")); // To set up the Look and Feel UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows." + "WindowsLookAndFeel"); frame = new MainFrame(); frame.setVisible(true); frame.correctTabStatus(); // To change the Look and Feel. To be included as an option some day... // UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk."+ // "GTKLookAndFeel"); // SwingUtilities.updateComponentTreeUI(frame); // frame.pack(); } catch (Exception e) { Logger.logFatal(Start.class, e); if (frame != null) { frame.showErrorMessage(Resourcer.getString(null, "error.internal")); frame.dispose(); } else { try { JOptionPane.showMessageDialog(null, Resourcer.getString(Start.class, "error.internal"), Resourcer.getString(Start.class, "error.title"), JOptionPane.ERROR_MESSAGE); } catch (Exception e2) { String message = ""; // This is the last resort to give a localized message // As I'm spanish :-), we give a spanish message if it's // the default language, and an english one otherwise. if (Locale.getDefault().getLanguage().equals(new Locale("es", "", "").getLanguage())) { message = message_es; } else { message = message_en; } JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE); } } System.exit(1); } catch (InternalError e) { Logger.logFatal(Start.class, e); if (frame != null) { frame.showErrorMessage(Resourcer.getString(null, "error.internal")); frame.dispose(); } else { try { JOptionPane.showMessageDialog(null, Resourcer.getString(Start.class, "error.internal"), Resourcer.getString(Start.class, "error.title"), JOptionPane.ERROR_MESSAGE); } catch (Exception e2) { String message = ""; // This is the last resort to give a localized message // As I'm spanish :-), we give a spanish message if it's // the default language, and an english one otherwise. if (Locale.getDefault().getLanguage().equals(new Locale("es", "", "").getLanguage())) { message = message_es; } else { message = message_en; } JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE); } } System.exit(1); } }
From source file:org.caffinitas.ohc.benchmark.BenchmarkOHC.java
public static void main(String[] args) throws Exception { Locale.setDefault(Locale.ENGLISH); Locale.setDefault(Locale.Category.FORMAT, Locale.ENGLISH); try {//from w w w. jav a2s .c om CommandLine cmd = parseArguments(args); String[] warmUp = cmd.getOptionValue(WARM_UP, "15,5").split(","); int warmUpSecs = Integer.parseInt(warmUp[0]); int coldSleepSecs = Integer.parseInt(warmUp[1]); int duration = Integer.parseInt(cmd.getOptionValue(DURATION, "60")); int cores = Runtime.getRuntime().availableProcessors(); if (cores >= 8) cores -= 2; else if (cores > 2) cores--; int threads = Integer.parseInt(cmd.getOptionValue(THREADS, Integer.toString(cores))); long capacity = Long.parseLong(cmd.getOptionValue(CAPACITY, "" + (1024 * 1024 * 1024))); int hashTableSize = Integer.parseInt(cmd.getOptionValue(HASH_TABLE_SIZE, "0")); int segmentCount = Integer.parseInt(cmd.getOptionValue(SEGMENT_COUNT, "0")); float loadFactor = Float.parseFloat(cmd.getOptionValue(LOAD_FACTOR, "0")); int keyLen = Integer.parseInt(cmd.getOptionValue(KEY_LEN, "0")); int chunkSize = Integer.parseInt(cmd.getOptionValue(CHUNK_SIZE, "-1")); int fixedKeySize = Integer.parseInt(cmd.getOptionValue(FIXED_KEY_SIZE, "-1")); int fixedValueSize = Integer.parseInt(cmd.getOptionValue(FIXED_VALUE_SIZE, "-1")); int maxEntrySize = Integer.parseInt(cmd.getOptionValue(MAX_ENTRY_SIZE, "-1")); boolean unlocked = Boolean.parseBoolean(cmd.getOptionValue(UNLOCKED, "false")); HashAlgorithm hashMode = HashAlgorithm.valueOf(cmd.getOptionValue(HASH_MODE, "MURMUR3")); boolean bucketHistogram = Boolean.parseBoolean(cmd.getOptionValue(BUCKET_HISTOGRAM, "false")); double readWriteRatio = Double.parseDouble(cmd.getOptionValue(READ_WRITE_RATIO, ".5")); Driver[] drivers = new Driver[threads]; Random rnd = new Random(); String readKeyDistStr = cmd.getOptionValue(READ_KEY_DIST, DEFAULT_KEY_DIST); String writeKeyDistStr = cmd.getOptionValue(WRITE_KEY_DIST, DEFAULT_KEY_DIST); String valueSizeDistStr = cmd.getOptionValue(VALUE_SIZE_DIST, DEFAULT_VALUE_SIZE_DIST); DistributionFactory readKeyDist = OptionDistribution.get(readKeyDistStr); DistributionFactory writeKeyDist = OptionDistribution.get(writeKeyDistStr); DistributionFactory valueSizeDist = OptionDistribution.get(valueSizeDistStr); for (int i = 0; i < threads; i++) { drivers[i] = new Driver(readKeyDist.get(), writeKeyDist.get(), valueSizeDist.get(), readWriteRatio, rnd.nextLong()); } printMessage("Initializing OHC cache..."); OHCacheBuilder<Long, byte[]> builder = OHCacheBuilder.<Long, byte[]>newBuilder() .keySerializer( keyLen <= 0 ? BenchmarkUtils.longSerializer : new BenchmarkUtils.KeySerializer(keyLen)) .valueSerializer(BenchmarkUtils.serializer).capacity(capacity); if (cmd.hasOption(LOAD_FACTOR)) builder.loadFactor(loadFactor); if (cmd.hasOption(SEGMENT_COUNT)) builder.segmentCount(segmentCount); if (cmd.hasOption(HASH_TABLE_SIZE)) builder.hashTableSize(hashTableSize); if (cmd.hasOption(CHUNK_SIZE)) builder.chunkSize(chunkSize); if (cmd.hasOption(MAX_ENTRY_SIZE)) builder.maxEntrySize(maxEntrySize); if (cmd.hasOption(UNLOCKED)) builder.unlocked(unlocked); if (cmd.hasOption(HASH_MODE)) builder.hashMode(hashMode); if (cmd.hasOption(FIXED_KEY_SIZE)) builder.fixedEntrySize(fixedKeySize, fixedValueSize); Shared.cache = builder.build(); printMessage("Cache configuration: instance : %s%n" + " hash-table-size: %d%n" + " load-factor : %.3f%n" + " segments : %d%n" + " capacity : %d%n", Shared.cache, Shared.cache.hashTableSizes()[0], Shared.cache.loadFactor(), Shared.cache.segments(), Shared.cache.capacity()); String csvFileName = cmd.getOptionValue(CSV, null); PrintStream csv = null; if (csvFileName != null) { File csvFile = new File(csvFileName); csv = new PrintStream(new FileOutputStream(csvFile)); csv.println("# OHC benchmark - http://github.com/snazy/ohc"); csv.println("# "); csv.printf("# started on %s (%s)%n", InetAddress.getLocalHost().getHostName(), InetAddress.getLocalHost().getHostAddress()); csv.println("# "); csv.printf("# Warum-up/sleep seconds: %d / %d%n", warmUpSecs, coldSleepSecs); csv.printf("# Duration: %d seconds%n", duration); csv.printf("# Threads: %d%n", threads); csv.printf("# Capacity: %d bytes%n", capacity); csv.printf("# Read/Write Ratio: %f%n", readWriteRatio); csv.printf("# Segment Count: %d%n", segmentCount); csv.printf("# Hash table size: %d%n", hashTableSize); csv.printf("# Load Factor: %f%n", loadFactor); csv.printf("# Additional key len: %d%n", keyLen); csv.printf("# Read key distribution: '%s'%n", readKeyDistStr); csv.printf("# Write key distribution: '%s'%n", writeKeyDistStr); csv.printf("# Value size distribution: '%s'%n", valueSizeDistStr); csv.printf("# Type: %s%n", Shared.cache.getClass().getName()); csv.println("# "); csv.printf("# started at %s%n", new Date()); Properties props = System.getProperties(); csv.printf("# java.version: %s%n", props.get("java.version")); for (Map.Entry<Object, Object> e : props.entrySet()) { String k = (String) e.getKey(); if (k.startsWith("org.caffinitas.ohc.")) csv.printf("# %s: %s%n", k, e.getValue()); } csv.printf("# number of cores: %d%n", Runtime.getRuntime().availableProcessors()); csv.println("# "); csv.println("\"runtime\";" + "\"r_count\";" + "\"r_oneMinuteRate\";\"r_fiveMinuteRate\";\"r_fifteenMinuteRate\";\"r_meanRate\";" + "\"r_snapMin\";\"r_snapMax\";\"r_snapMean\";\"r_snapStdDev\";" + "\"r_snap75\";\"r_snap95\";\"r_snap98\";\"r_snap99\";\"r_snap999\";\"r_snapMedian\";" + "\"w_count\";" + "\"w_oneMinuteRate\";\"w_fiveMinuteRate\";\"w_fifteenMinuteRate\";\"w_meanRate\";" + "\"w_snapMin\";\"w_snapMax\";\"w_snapMean\";\"w_snapStdDev\";" + "\"w_snap75\";\"w_snap95\";\"w_snap98\";\"w_snap99\";\"w_snap999\";\"w_snapMedian\""); } printMessage( "Starting benchmark with%n" + " threads : %d%n" + " warm-up-secs: %d%n" + " idle-secs : %d%n" + " runtime-secs: %d%n", threads, warmUpSecs, coldSleepSecs, duration); ThreadPoolExecutor main = new ThreadPoolExecutor(threads, threads, coldSleepSecs + 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() { volatile int threadNo; public Thread newThread(Runnable r) { return new Thread(r, "driver-main-" + threadNo++); } }); main.prestartAllCoreThreads(); // warm up if (warmUpSecs > 0) { printMessage("Start warm-up..."); runFor(warmUpSecs, main, drivers, bucketHistogram, csv); printMessage(""); logMemoryUse(); if (csv != null) csv.println("# warm up complete"); } // cold sleep if (coldSleepSecs > 0) { printMessage("Warm up complete, sleep for %d seconds...", coldSleepSecs); Thread.sleep(coldSleepSecs * 1000L); } // benchmark printMessage("Start benchmark..."); runFor(duration, main, drivers, bucketHistogram, csv); printMessage(""); logMemoryUse(); if (csv != null) csv.println("# benchmark complete"); // finish if (csv != null) csv.close(); System.exit(0); } catch (Throwable t) { t.printStackTrace(); System.exit(1); } }
From source file:org.eclipse.jubula.documentation.gen.TexGen.java
/** * @param args The program arguments//w w w.j a v a 2 s . com * @throws Exception If an error occurs */ public static void main(String[] args) throws Exception { Options options = createOptions(); CommandLine cl = null; try { CommandLineParser parser = new GnuParser(); cl = parser.parse(options, args); } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar texgen.jar", options, true); //$NON-NLS-1$ return; } String templateDir = cl.getOptionValue("td"); //$NON-NLS-1$ String outputDir = cl.getOptionValue("od"); //$NON-NLS-1$ if (cl.hasOption("nl")) { //$NON-NLS-1$ Locale.setDefault(new Locale(cl.getOptionValue("nl"))); //$NON-NLS-1$ } String gType = "actions"; //$NON-NLS-1$ if (cl.hasOption("gt")) { //$NON-NLS-1$ gType = cl.getOptionValue("gt"); //$NON-NLS-1$ } if (gType.equals("actions")) { //$NON-NLS-1$ handleActions(templateDir, outputDir); } else if (gType.equals("errors")) { //$NON-NLS-1$ handleErrors(templateDir, outputDir); } }
From source file:org.movsim.consumption.ConsumptionMain.java
public static void main(String[] args) { Locale.setDefault(Locale.US); System.out.println(/* w w w .jav a2 s.c om*/ "Movsim Energy-Flow Model (Consumption). (c) Arne Kesting, Martin Treiber, Ralph Germ, Martin Budden, see: www.movsim.org"); Logger.initializeLogger(); MovsimCommandLine.parse(args); ConsumptionMain consumptionMain = new ConsumptionMain(); consumptionMain.run(); }