List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:com.adito.upgrade.Upgrade.java
/** * @param args/* www . jav a 2 s . c o m*/ * @throws Exception on any error */ public static void main(String[] args) throws Exception { boolean gui = System.getProperty("os.name").toLowerCase().startsWith("windows") || System.getenv("DISPLAY") != null; if (args.length == 2 || !gui) { Upgrader upgrader = new CommandLineUpgrader(args); upgrader.upgrade(); } else { JFrame f = new JFrame("0.1.16 to 0.2.5+ Upgrader"); final Upgrader upgrader = new GUIUpgrader(); f.setIconImage(new ImageIcon(Upgrade.class.getResource("upgrader-32x32.png")).getImage()); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add((JPanel) upgrader, BorderLayout.CENTER); f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); JPanel bp = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton start = new JButton("Start"); ; final JButton close = new JButton("Close"); start.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { start.setEnabled(false); close.setEnabled(false); upgrader.upgrade(); } catch (Exception ex) { upgrader.error("Failed to upgrade.", ex); } finally { close.setEnabled(true); } } }); close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (close.isEnabled()) System.exit(0); } }); bp.add(start); bp.add(close); f.getContentPane().add(bp, BorderLayout.SOUTH); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { if (close.isEnabled()) System.exit(0); } }); f.setSize(new Dimension(480, 460)); UIUtil.positionComponent(SwingConstants.CENTER, f); f.setVisible(true); } }
From source file:org.jinglenodes.Main.java
/** * @param args command (start, stop)/*from w ww . j a v a 2 s . c o m*/ */ public static void main(String[] args) { appDir = System.getProperty("sipgateway.home"); if (appDir == null) appDir = System.getProperty("user.home") + "/sipgateway/"; if (args.length > 0) { final String opt = args[0].toLowerCase(); if ("start".equals(opt)) { start(defaultSprinfFile); return; } else if ("stop".equals(opt)) { stop(); return; } } System.err.println("Usage: Main start/stop"); System.err.println("\nOptions:"); System.err.println(" start - Starts SIP Gateway using the configuration files"); System.err.println(" stop - Stop the Application Engine"); }
From source file:eu.pawelsz.apache.beam.coders.TupleCoderGenerator.java
public static void main(String[] args) throws Exception { System.err.println("Current directory " + System.getProperty("user.dir")); String rootDir = ROOT_DIRECTORY; if (args.length > 0) { rootDir = args[0] + "/" + ROOT_DIRECTORY; }/*from w w w. java 2s. co m*/ System.err.println("Using root directory: " + rootDir); File root = new File(rootDir); createTupleClasses(root); }
From source file:com.couchbase.client.neo4j.Neo4jSync.java
/** * @param args/* ww w . j ava 2 s. co m*/ */ public static void main(String[] args) { String configurationFile = System.getProperty("conf.file"); Validate.notBlank(configurationFile, "Use: -Dconf.file=<configuration_file>"); Neo4jSyncConfManager confManager = new PropertiesNeo4jSyncConfManager(configurationFile); log.info("configure DCP client on {}[{}]", confManager.getCouchbaseHostname(), confManager.getCouchbaseBucket()); //TODO password? // Connect to Couchbase DCP final Client client = Client.configure().hostnames(confManager.getCouchbaseHostname()) .bucket(confManager.getCouchbaseBucket()).build(); BoltNeo4jConnector connector = new BoltNeo4jConnector(); connector.init(confManager); //FIXME manage rollback Neo4jControlEventHandler controlEventHandler = new Neo4jControlEventHandler(); controlEventHandler.init(client); log.info("configure BoltNeo4jConnector as neo4jConnector"); log.info("configure Neo4jDataEventHandler as dataEventHandler"); Neo4jDataEventHandler dataEventHandler = new Neo4jDataEventHandler(); dataEventHandler.setConnector(connector); client.dataEventHandler(dataEventHandler); // Connect the sockets client.connect().await(); // Initialize the state (start now, never stop) log.info("initialize stream from NOW to INFINITY"); client.initializeState(StreamFrom.NOW, StreamTo.INFINITY).await(); // Start streaming on all partitions client.startStreaming().await(); //NEVER STOP }
From source file:demo.hw.client.SpringClient.java
public static void main(String args[]) throws Exception { // START SNIPPET: client ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "/demo/hw/client/client-beans.xml" }); Greeter port = (Greeter) context.getBean("client"); String resp;/*from w ww . j a v a 2 s . c o m*/ System.out.println("Invoking sayHi..."); resp = port.sayHi(); System.out.println("Server responded with: " + resp); System.out.println(); System.out.println("Invoking greetMe..."); resp = port.greetMe(System.getProperty("user.name")); System.out.println("Server responded with: " + resp); System.out.println(); System.out.println("Invoking greetMe with invalid length string, expecting exception..."); try { resp = port.greetMe("Invoking greetMe with invalid length string, expecting exception..."); } catch (WebServiceException ex) { System.out.println("Caught expected WebServiceException:"); System.out.println(" " + ex.getMessage()); } System.out.println(); System.out.println("Invoking greetMeOneWay..."); port.greetMeOneWay(System.getProperty("user.name")); System.out.println("No response from server as method is OneWay"); System.out.println(); try { System.out.println("Invoking pingMe, expecting exception..."); port.pingMe(); } catch (PingMeFault ex) { System.out.println("Expected exception: PingMeFault has occurred: " + ex.getMessage()); FaultDetailDocument detailDocument = ex.getFaultInfo(); FaultDetail detail = detailDocument.getFaultDetail(); System.out.println("FaultDetail major:" + detail.getMajor()); System.out.println("FaultDetail minor:" + detail.getMinor()); } System.exit(0); // END SNIPPET: client }
From source file:de.dakror.scpuller.SCPuller.java
public static void main(String[] args) { new File(System.getProperty("user.home") + "/.dakror/SCPuller").mkdirs(); new File(System.getProperty("user.home") + "/.dakror/SCPuller/download").mkdir(); Scanner scanner = new Scanner(System.in); loadDownloadedSongs();/*from w w w .j a v a 2 s .c om*/ try { while (true) { String line = scanner.nextLine().trim(); download(line); saveDownloadedSongs(); } } finally { scanner.close(); } }
From source file:UserNameTest.java
public static void main(String[] args) { String name = System.getProperty("user.name"); System.out.println(name); }
From source file:it.anyplace.sync.webclient.Main.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("C", "set-config", true, "set config file for s-client"); options.addOption("h", "help", false, "print help"); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("s-client", options); return;/*from w w w . j a v a 2 s .c o m*/ } File configFile = cmd.hasOption("C") ? new File(cmd.getOptionValue("C")) : new File(System.getProperty("user.home"), ".s-client.properties"); logger.info("using config file = {}", configFile); try (ConfigurationService configuration = ConfigurationService.newLoader().loadFrom(configFile)) { FileUtils.cleanDirectory(configuration.getTemp()); KeystoreHandler.newLoader().loadAndStore(configuration); logger.debug("{}", configuration.getStorageInfo().dumpAvailableSpace()); try (HttpService httpService = new HttpService(configuration)) { httpService.start(); if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse( URI.create("http://localhost:" + httpService.getPort() + "/web/webclient.html")); } httpService.join(); } } }
From source file:groovesquid.Main.java
public static void main(String[] args) { System.setSecurityManager(null); log.log(Level.INFO, "Groovesquid v{0} running on {1} {2} ({3}) in {4}", new Object[] { version, System.getProperty("java.vm.name"), System.getProperty("java.runtime.version"), System.getProperty("java.vm.vendor"), System.getProperty("java.home") }); // show gui//from www . j a v a 2 s . co m // apple os x System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Groovesquid"); // antialising System.setProperty("awt.useSystemAAFontSettings", "lcd"); System.setProperty("swing.aatext", "true"); // flackering bg fix System.setProperty("sun.awt.noerasebackground", "true"); System.setProperty("sun.java2d.noddraw", "true"); Toolkit.getDefaultToolkit().setDynamicLayout(true); try { //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { log.log(Level.SEVERE, null, ex); } // load languages languages = loadLanguages(); // Load config config = loadConfig(); // GUI try { gui = (GUI) config.getGuiClass().newInstance(); } catch (InstantiationException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } settings = new Settings(); about = new About(); // Update Checker new UpdateCheckThread().start(); // init grooveshark (every 25min) new InitThread().start(); }
From source file:com.turbospaces.api.EmbeddedJSpaceRunner.java
/** * launcher method/*from ww w . j ava2 s. co m*/ * * @param args * [1 argument = application context path] * @throws Exception * re-throw execution errors if any */ public static void main(final String... args) throws Exception { JVMUtil.gcOnExit(); String appContextPath = args[0]; if (System.getProperty(Global.IPv4) == null && System.getProperty(Global.IPv6) == null) System.setProperty(Global.IPv4, Boolean.TRUE.toString()); System.setProperty(Global.CUSTOM_LOG_FACTORY, JGroupsCustomLoggerFactory.class.getName()); LOGGER.info("Welcome to turbospaces:version = {}, build date = {}", SpaceUtility.projectVersion(), SpaceUtility.projecBuildTimestamp()); LOGGER.info("{}: launching configuration {}", EmbeddedJSpaceRunner.class.getSimpleName(), appContextPath); AbstractXmlApplicationContext c = appContextPath.startsWith("file") ? new FileSystemXmlApplicationContext(appContextPath) : new ClassPathXmlApplicationContext(appContextPath); c.getBeansOfType(JSpace.class); c.registerShutdownHook(); Collection<SpaceConfiguration> configurations = c.getBeansOfType(SpaceConfiguration.class).values(); for (SpaceConfiguration spaceConfiguration : configurations) spaceConfiguration.joinNetwork(); LOGGER.info("all jspaces joined network, notifying waiting threads..."); synchronized (joinNetworkMonitor) { joinNetworkMonitor.notifyAll(); } while (!Thread.currentThread().isInterrupted()) synchronized (c) { try { c.wait(TimeUnit.SECONDS.toMillis(1)); } catch (InterruptedException e) { LOGGER.info("got interruption signal, terminating jspaces... stack_trace = {}", Throwables.getStackTraceAsString(e)); Thread.currentThread().interrupt(); Util.printThreads(); } } c.destroy(); }