List of usage examples for java.lang Runtime getRuntime
public static Runtime getRuntime()
From source file:fr.inria.atlanmod.atl_mr.utils.NeoEMFHBaseMigrator.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input file, both of xmi and zxmi extensions are supported"); inputOpt.setArgs(1);/* w w w . j a va 2 s .co m*/ inputOpt.setRequired(true); Option outputOpt = OptionBuilder.create(OUT); outputOpt.setArgName("OUTPUT"); outputOpt.setDescription("Output HBase resource URI"); outputOpt.setArgs(1); outputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(E_PACKAGE); inClassOpt.setArgName("METAMODEL"); inClassOpt.setDescription("URI of the ecore Metamodel"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); options.addOption(inputOpt); options.addOption(outputOpt); options.addOption(inClassOpt); CommandLineParser parser = new PosixParser(); try { CommandLine commandLine = parser.parse(options, args); URI sourceUri = URI.createFileURI(commandLine.getOptionValue(IN)); URI targetUri = URI.createURI(commandLine.getOptionValue(OUT)); URI metamodelUri = URI.createFileURI(commandLine.getOptionValue(E_PACKAGE)); NeoEMFHBaseMigrator.class.getClassLoader().loadClass(commandLine.getOptionValue(E_PACKAGE)) .getMethod("init").invoke(null); //org.eclipse.gmt.modisco.java.kyanos.impl.JavaPackageImpl.init(); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("zxmi", new XMIResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put(KyanosURI.KYANOS_HBASE_SCHEME, KyanosResourceFactory.eINSTANCE); //Registering the metamodel // Resource MMResource = resourceSet.createResource(metamodelUri); // MMResource.load(Collections.EMPTY_MAP); // ATLMRUtils.registerPackages(resourceSet, MMResource); //Loading the XMI resource Resource sourceResource = resourceSet.createResource(sourceUri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if ("zxmi".equals(sourceUri.fileExtension())) { loadOpts.put(XMIResource.OPTION_ZIP, Boolean.TRUE); } Runtime.getRuntime().gc(); long initialUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); LOG.log(Level.INFO, MessageFormat.format("Used memory before loading: {0}", ATLMRUtils.byteCountToDisplaySize(initialUsedMemory))); LOG.log(Level.INFO, "Loading source resource"); sourceResource.load(loadOpts); LOG.log(Level.INFO, "Source resource loaded"); Runtime.getRuntime().gc(); long finalUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); LOG.log(Level.INFO, MessageFormat.format("Used memory after loading: {0}", ATLMRUtils.byteCountToDisplaySize(finalUsedMemory))); LOG.log(Level.INFO, MessageFormat.format("Memory use increase: {0}", ATLMRUtils.byteCountToDisplaySize(finalUsedMemory - initialUsedMemory))); Resource targetResource = resourceSet.createResource(targetUri); Map<String, Object> saveOpts = new HashMap<String, Object>(); targetResource.save(saveOpts); LOG.log(Level.INFO, "Start moving elements"); targetResource.getContents().clear(); targetResource.getContents().addAll(sourceResource.getContents()); LOG.log(Level.INFO, "End moving elements"); LOG.log(Level.INFO, "Start saving"); targetResource.save(saveOpts); LOG.log(Level.INFO, "Saved"); if (targetResource instanceof KyanosHbaseResourceImpl) { KyanosHbaseResourceImpl.shutdownWithoutUnload((KyanosHbaseResourceImpl) targetResource); } else { targetResource.unload(); } } catch (ParseException e) { ATLMRUtils.showError(e.toString()); ATLMRUtils.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { ATLMRUtils.showError(e.toString()); e.printStackTrace(); } }
From source file:com.amazon.kinesis.streaming.agent.Agent.java
public static void main(String[] args) throws Exception { AgentOptions opts = AgentOptions.parse(args); String configFile = opts.getConfigFile(); AgentConfiguration config = tryReadConfigurationFile(Paths.get(opts.getConfigFile())); Path logFile = opts.getLogFile() != null ? Paths.get(opts.getLogFile()) : (config != null ? config.logFile() : null); String logLevel = opts.getLogLevel() != null ? opts.getLogLevel() : (config != null ? config.logLevel() : null); int logMaxBackupFileIndex = (config != null ? config.logMaxBackupIndex() : -1); long logMaxFileSize = (config != null ? config.logMaxFileSize() : -1L); Logging.initialize(logFile, logLevel, logMaxBackupFileIndex, logMaxFileSize); final Logger logger = Logging.getLogger(Agent.class); // Install an unhandled exception hook Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override//from w w w. ja va 2 s. c o m public void uncaughtException(Thread t, Throwable e) { if (e instanceof OutOfMemoryError) { // This prevents the JVM from hanging in case of an OOME dontShutdownOnExit = true; } String msg = "FATAL: Thread " + t.getName() + " threw an unrecoverable error. Aborting application"; try { try { // We don't know if logging is still working logger.error(msg, e); } finally { System.err.println(msg); e.printStackTrace(); } } finally { System.exit(1); } } }); try { logger.info("Reading configuration from file: {}", configFile); if (config == null) { config = readConfigurationFile(Paths.get(opts.getConfigFile())); } // Initialize and start the agent AgentContext agentContext = new AgentContext(config); if (agentContext.flows().isEmpty()) { throw new ConfigurationException("There are no flows configured in configuration file."); } final Agent agent = new Agent(agentContext); // Make sure everything terminates cleanly when process is killed Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { if (!dontShutdownOnExit && agent.isRunning()) { agent.stopAsync(); agent.awaitTerminated(); } } }); agent.startAsync(); agent.awaitRunning(); agent.awaitTerminated(); } catch (Exception e) { logger.error("Unhandled error.", e); System.err.println("Unhandled error."); e.printStackTrace(); System.exit(1); } }
From source file:fr.inria.atlanmod.kyanos.benchmarks.KyanosMapCreator.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input file"); inputOpt.setArgs(1);//from www .ja v a 2s . com inputOpt.setRequired(true); Option outputOpt = OptionBuilder.create(OUT); outputOpt.setArgName("OUTPUT"); outputOpt.setDescription("Output directory"); outputOpt.setArgs(1); outputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); options.addOption(inputOpt); options.addOption(outputOpt); options.addOption(inClassOpt); CommandLineParser parser = new PosixParser(); try { PersistenceBackendFactoryRegistry.getFactories().put(NeoMapURI.NEO_MAP_SCHEME, new MapPersistenceBackendFactory()); CommandLine commandLine = parser.parse(options, args); URI sourceUri = URI.createFileURI(commandLine.getOptionValue(IN)); URI targetUri = NeoMapURI.createNeoMapURI(new File(commandLine.getOptionValue(OUT))); Class<?> inClazz = KyanosMapCreator.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("zxmi", new XMIResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put(NeoMapURI.NEO_MAP_SCHEME, PersistentResourceFactory.eINSTANCE); Resource sourceResource = resourceSet.createResource(sourceUri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if ("zxmi".equals(sourceUri.fileExtension())) { loadOpts.put(XMIResource.OPTION_ZIP, Boolean.TRUE); } Runtime.getRuntime().gc(); long initialUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); LOG.log(Level.INFO, MessageFormat.format("Used memory before loading: {0}", MessageUtil.byteCountToDisplaySize(initialUsedMemory))); LOG.log(Level.INFO, "Loading source resource"); sourceResource.load(loadOpts); LOG.log(Level.INFO, "Source resource loaded"); Runtime.getRuntime().gc(); long finalUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); LOG.log(Level.INFO, MessageFormat.format("Used memory after loading: {0}", MessageUtil.byteCountToDisplaySize(finalUsedMemory))); LOG.log(Level.INFO, MessageFormat.format("Memory use increase: {0}", MessageUtil.byteCountToDisplaySize(finalUsedMemory - initialUsedMemory))); Resource targetResource = resourceSet.createResource(targetUri); Map<String, Object> saveOpts = new HashMap<String, Object>(); List<StoreOption> storeOptions = new ArrayList<StoreOption>(); storeOptions.add(MapResourceOptions.EStoreMapOption.AUTOCOMMIT); saveOpts.put(MapResourceOptions.STORE_OPTIONS, storeOptions); targetResource.save(saveOpts); LOG.log(Level.INFO, "Start moving elements"); targetResource.getContents().clear(); targetResource.getContents().addAll(sourceResource.getContents()); LOG.log(Level.INFO, "End moving elements"); LOG.log(Level.INFO, "Start saving"); targetResource.save(saveOpts); LOG.log(Level.INFO, "Saved"); if (targetResource instanceof PersistentResourceImpl) { PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) targetResource); } else { targetResource.unload(); } } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); e.printStackTrace(); } }
From source file:com.uber.stream.kafka.mirrormaker.manager.ManagerStarter.java
public static void main(String[] args) throws Exception { CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(ManagerConf.constructManagerOptions(), args); if (cmd.getOptions().length == 0 || cmd.hasOption("help")) { HelpFormatter f = new HelpFormatter(); f.printHelp("OptionsTip", ManagerConf.constructManagerOptions()); System.exit(0);//from ww w .ja va2 s. c o m } final ManagerStarter managerStarter = ManagerStarter.init(cmd); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { managerStarter.stop(); } catch (Exception e) { LOGGER.error("Caught error during shutdown! ", e); } } }); try { managerStarter.start(); } catch (Exception e) { LOGGER.error("Cannot start uReplicator-Manager: ", e); } }
From source file:de.cwclan.cwsa.serverendpoint.main.ServerEndpoint.java
/** * @param args the command line arguments *///from ww w . ja v a2s .com public static void main(String[] args) { Options options = new Options(); options.addOption(OptionBuilder.withArgName("file").hasArg().withDescription( "Used to enter path of configfile. Default file is endpoint.properties. NOTE: If the file is empty or does not exsist, a default config is created.") .create("config")); options.addOption("h", "help", false, "displays this page"); CommandLineParser parser = new PosixParser(); Properties properties = new Properties(); try { /* * parse default config shipped with jar */ CommandLine cmd = parser.parse(options, args); /* * load default configuration */ InputStream in = ServerEndpoint.class.getResourceAsStream("/endpoint.properties"); if (in == null) { throw new IOException("Unable to load default config from JAR. This should not happen."); } properties.load(in); in.close(); log.debug("Loaded default config base: {}", properties.toString()); if (cmd.hasOption("help")) { printHelp(options); System.exit(0); } /* * parse cutom config if exists, otherwise create default cfg */ if (cmd.hasOption("config")) { File file = new File(cmd.getOptionValue("config", "endpoint.properties")); if (file.exists() && file.canRead() && file.isFile()) { in = new FileInputStream(file); properties.load(in); log.debug("Loaded custom config from {}: {}", file.getAbsoluteFile(), properties); } else { log.warn("Config file does not exsist. A default file will be created."); } FileWriter out = new FileWriter(file); properties.store(out, "Warning, this file is recreated on every startup to merge missing parameters."); } /* * create and start endpoint */ log.info("Config read successfull. Values are: {}", properties); ServerEndpoint endpoint = new ServerEndpoint(properties); Runtime.getRuntime().addShutdownHook(endpoint.getShutdownHook()); endpoint.start(); } catch (IOException ex) { log.error("Error while reading config.", ex); } catch (ParseException ex) { log.error("Error while parsing commandline options: {}", ex.getMessage()); printHelp(options); System.exit(1); } }
From source file:mcnutty.music.get.MusicGet.java
public static void main(String[] args) throws Exception { //print out music-get System.out.println(" _ _ "); System.out.println(" _ __ ___ _ _ ___(_) ___ __ _ ___| |_ "); System.out.println("| '_ ` _ \\| | | / __| |/ __|____ / _` |/ _ \\ __|"); System.out.println("| | | | | | |_| \\__ \\ | (_|_____| (_| | __/ |_ "); System.out.println("|_| |_| |_|\\__,_|___/_|\\___| \\__, |\\___|\\__|"); System.out.println(" |___/ \n"); //these will always be initialised later (but the compiler doesn't know that) String directory = ""; Properties prop = new Properties(); try (InputStream input = new FileInputStream("config.properties")) { prop.load(input);/*from w w w . j a va 2 s .c o m*/ if (prop.getProperty("directory") != null) { directory = prop.getProperty("directory"); } else { System.out.println( "Error reading config property 'directory' - using default value of /tmp/musicserver/\n"); directory = "/tmp/musicserver/"; } if (prop.getProperty("password") == null) { System.out.println("Error reading config property 'password' - no default value, exiting\n"); System.exit(1); } } catch (IOException e) { System.out.println("Error reading config file"); System.exit(1); } //create a queue object ProcessQueue process_queue = new ProcessQueue(); try { if (args.length > 0 && args[0].equals("clean")) { Files.delete(Paths.get("queue.json")); } //load an existing queue if possible String raw_queue = Files.readAllLines(Paths.get("queue.json")).toString(); JSONArray queue_state = new JSONArray(raw_queue); ConcurrentLinkedQueue<QueueItem> loaded_queue = new ConcurrentLinkedQueue<>(); JSONArray queue = queue_state.getJSONArray(0); for (int i = 0; i < queue.length(); i++) { JSONObject item = ((JSONObject) queue.get(i)); QueueItem loaded_item = new QueueItem(); loaded_item.ip = item.getString("ip"); loaded_item.real_name = item.getString("name"); loaded_item.disk_name = item.getString("guid"); loaded_queue.add(loaded_item); } process_queue.bucket_queue = loaded_queue; System.out.println("Loaded queue from disk\n"); } catch (Exception ex) { //otherwise clean out the music directory and start a new queue try { Files.walkFileTree(Paths.get(directory), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } }); Files.delete(Paths.get(directory)); } catch (Exception e) { e.printStackTrace(); } Files.createDirectory(Paths.get(directory)); System.out.println("Created a new queue\n"); } //start the web server StartServer start_server = new StartServer(process_queue, directory); new Thread(start_server).start(); //wit for the web server to spool up Thread.sleep(1000); //read items from the queue and play them while (true) { QueueItem next_item = process_queue.next_item(); if (!next_item.equals(new QueueItem())) { //Check the timeout int timeout = 547; try (FileInputStream input = new FileInputStream("config.properties")) { prop.load(input); timeout = Integer.parseInt(prop.getProperty("timeout", "547")); } catch (Exception e) { e.printStackTrace(); } System.out.println("Playing " + next_item.real_name); process_queue.set_played(next_item); process_queue.save_queue(); Process p = Runtime.getRuntime().exec("timeout " + timeout + "s mplayer -fs -quiet -af volnorm=2:0.25 " + directory + next_item.disk_name); try { p.waitFor(timeout, TimeUnit.SECONDS); Files.delete(Paths.get(directory + next_item.disk_name)); } catch (Exception e) { e.printStackTrace(); } } else { process_queue.bucket_played.clear(); } Thread.sleep(1000); } }
From source file:com.francetelecom.rd.dashboard.pc.DashboardPC.java
/** * Launch the application.// w w w. j av a 2 s .c om */ public static void main(String[] args) { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { logger.info("Application close, will unpublish node!"); myNode.unPublishFromHomeBus(); } catch (HomeBusException e) { logger.error("Application close, could not unpublish node : " + e.getMessage()); e.printStackTrace(); } } }); EventQueue.invokeLater(new Runnable() { public void run() { try { DashboardPC frame = new DashboardPC(); String nodeId = frame.getIdForType(ID_type_Node); frame.busFactory = new HomeBusFactory(nodeId); try { // temporary solution // fake solution // must remove this sleep after sds will no longer need it Thread.sleep(1000); } catch (Exception e) { logger.error("Error while sleep before node publish! \n" + e.getMessage()); } frame.initNode(nodeId); frame.initDashboardWithRules(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:de.huberlin.wbi.cuneiform.cmdline.main.Main.java
public static void main(String[] args) throws IOException, ParseException, InterruptedException, NotDerivableException { CommandLine cmd;//from ww w .j a v a 2 s .c o m Options opt; BaseRepl repl; BaseCreActor cre; Path sandbox; ExecutorService executor; TicketSrcActor ticketSrc; JsonSummary summary; Path summaryPath; Log statLog; int nthread; Path workDir; statLog = LogFactory.getLog("statLogger"); executor = Executors.newCachedThreadPool(); try { opt = getOptions(); cmd = parse(args, opt); config(cmd); if (cmd.hasOption('h')) { System.out.println("CUNEIFORM - A Functional Workflow Language\nversion " + BaseRepl.LABEL_VERSION + " build " + BaseRepl.LABEL_BUILD); new HelpFormatter().printHelp("java -jar cuneiform.jar [OPTION]*", opt); return; } if (cmd.hasOption('r')) Invocation.putLibPath(ForeignLambdaExpr.LANGID_R, cmd.getOptionValue('r')); if (cmd.hasOption('y')) Invocation.putLibPath(ForeignLambdaExpr.LANGID_PYTHON, cmd.getOptionValue('y')); if (cmd.hasOption('l')) sandbox = Paths.get(cmd.getOptionValue("l")); else sandbox = Paths.get(System.getProperty("user.home")).resolve(".cuneiform"); sandbox = sandbox.toAbsolutePath(); if (cmd.hasOption('c')) LocalThread.deleteIfExists(sandbox); if (cmd.hasOption('t')) nthread = Integer.valueOf(cmd.getOptionValue('t')); else nthread = Runtime.getRuntime().availableProcessors(); if (cmd.hasOption('w')) workDir = Paths.get(cmd.getOptionValue('w')); else workDir = Paths.get(System.getProperty("user.dir")); workDir = workDir.toAbsolutePath(); switch (platform) { case PLATFORM_LOCAL: if (!Files.exists(sandbox)) Files.createDirectories(sandbox); cre = new LocalCreActor(sandbox, workDir, nthread); break; case PLATFORM_HTCONDOR: if (!Files.exists(sandbox)) Files.createDirectories(sandbox); if (cmd.hasOption('m')) { // MAX_TRANSFER SIZE String maxTransferSize = cmd.getOptionValue('m'); try { cre = new CondorCreActor(sandbox, maxTransferSize); } catch (Exception e) { System.out.println("INVALID '-m' option value: " + maxTransferSize + "\n\nCUNEIFORM - A Functional Workflow Language\nversion " + BaseRepl.LABEL_VERSION + " build " + BaseRepl.LABEL_BUILD); new HelpFormatter().printHelp("java -jar cuneiform.jar [OPTION]*", opt); return; } } else { cre = new CondorCreActor(sandbox); } break; default: throw new RuntimeException("Platform not recognized."); } executor.submit(cre); ticketSrc = new TicketSrcActor(cre); executor.submit(ticketSrc); executor.shutdown(); switch (format) { case FORMAT_CF: if (cmd.hasOption("i")) repl = new InteractiveRepl(ticketSrc, statLog); else repl = new CmdlineRepl(ticketSrc, statLog); break; case FORMAT_DAX: repl = new DaxRepl(ticketSrc, statLog); break; default: throw new RuntimeException("Format not recognized."); } if (cmd.hasOption("i")) { // run in interactive mode BaseRepl.run(repl); return; } // run in quiet mode if (inputFileVector.length > 0) for (Path f : inputFileVector) repl.interpret(readFile(f)); else repl.interpret(readStdIn()); Thread.sleep(3 * Actor.DELAY); while (repl.isBusy()) Thread.sleep(Actor.DELAY); if (cmd.hasOption("s")) { summary = new JsonSummary(ticketSrc.getRunId(), sandbox, repl.getAns()); summaryPath = Paths.get(cmd.getOptionValue("s")); summaryPath = summaryPath.toAbsolutePath(); try (BufferedWriter writer = Files.newBufferedWriter(summaryPath, Charset.forName("UTF-8"))) { writer.write(summary.toString()); } } } finally { executor.shutdownNow(); } }
From source file:com.salaboy.rolo.hardware.test.HardwareSerialTestCommandServer.java
public static void main(String[] args) throws Exception { Weld weld = new Weld(); WeldContainer container = weld.initialize(); HardwareSerialTestCommandServer roloCommandServer = container.instance() .select(HardwareSerialTestCommandServer.class).get(); // create Options object Options options = new Options(); // add t option options.addOption("t", true, "sensors latency"); options.addOption("ip", true, "host"); options.addOption("port", true, "port"); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); String sensorLatency = cmd.getOptionValue("t"); if (sensorLatency == null) { System.out.println(" The Default Latency will be used: " + defaultLatency); } else {/*from w w w . j a v a 2 s . co m*/ System.out.println(" The Latency will be set to: " + sensorLatency); defaultLatency = new Long(sensorLatency); } String ip = cmd.getOptionValue("ip"); if (ip == null) { System.out.println(" The Default IP will be used: 127.0.0.1"); roloCommandServer.setHost("127.0.0.1"); } else { System.out.println(" The IP will be set to: " + ip); roloCommandServer.setHost(ip); } String port = cmd.getOptionValue("port"); if (port == null) { System.out.println(" The Default Port will be used: 5445"); roloCommandServer.setPort(5445); } else { System.out.println(" The Port will be set to: " + port); roloCommandServer.setPort(Integer.parseInt(port)); } System.out.println("Starting Rolo ..."); Thread thread = new Thread(roloCommandServer); thread.start(); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { System.out.println("Shutdown Hook is running !"); } }); }
From source file:com.jsystem.j2autoit.AutoItAgent.java
/** * Launch the server side/*from w w w . j av a 2 s. com*/ * * @param args */ public static void main(String[] args) { try { Log.initLog(); isDebug = AutoItProperties.DEBUG_MODE_KEY.getValue(isDebug); isAutoDeleteFiles = AutoItProperties.AUTO_DELETE_TEMPORARY_SCRIPT_FILE_KEY.getValue(isAutoDeleteFiles); if (isAutoDeleteFiles) { Integer tempHistory = AutoItProperties.AUTO_IT_SCRIPT_HISTORY_SIZE_KEY .getValue(DEFAULT_HistorySize); HistoryFile.init(); HistoryFile.setHistory_Size(tempHistory); } isForceAutoItShutDown = AutoItProperties.FORCE_AUTO_IT_PROCESS_SHUTDOWN_KEY .getValue(isForceAutoItShutDown); webServicePort = AutoItProperties.AGENT_PORT_KEY.getValue(webServicePort); serverState = AutoItProperties.SERVER_UP_ON_INIT_KEY.getValue(serverState); Log.setLogMode(false, isDebug); Runtime.getRuntime().addShutdownHook(new ExitThread()); Log.info(System.getProperty("user.dir") + NEW_LINE); Log.info("AutoIt Location: " + getAutoExecuterItLocation("Unable to find") + NEW_LINE); startAutoItWebServer(webServicePort); if (serverState) { serverState = false; runWebServer(); } UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception exception) { Log.throwable(exception.getMessage() + NEW_LINE, exception); } /* Turn off metal's use of bold fonts */ UIManager.put("swing.boldMetal", Boolean.FALSE); //Schedule a job for the event-dispatching thread: //adding TrayIcon. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { createAndShowGUI(); } }); }