List of usage examples for java.lang System setProperty
public static String setProperty(String key, String value)
From source file:EmbedJTableSWTNoFlicker.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*/*www . ja v a2 s.c o m*/ * Set a Windows specific AWT property that prevents heavyweight components * from erasing their background. Note that this is a global property and * cannot be scoped. It might not be suitable for your application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector rows = new Vector(); for (int i = 0; i < nrows; i++) { Vector row = new Vector(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector columns = new Vector(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ru.mystamps.web.support.spring.boot.ApplicationBootstrap.java
public static void main(String... args) { System.setProperty("java.awt.headless", "true"); // @see http://www.slf4j.org/codes.html#loggerNameMismatch System.setProperty("slf4j.detectLoggerNameMismatch", "true"); ConfigurableApplicationContext context = SpringApplication.run(ApplicationBootstrap.class, args); FeatureManager featureManager = context.getBean(FeatureManager.class); StaticFeatureManagerProvider.setFeatureManager(featureManager); }
From source file:org.yamj.filescanner.FileScanner.java
public static void main(String[] args) throws IOException { System.setProperty("file.name", LOG_FILENAME); PropertyConfigurator.configure("config/log4j.properties"); // Get the current directory String yamjHome = ClassTools.checkSystemProperty("yamj3.home", (new File(".")).getCanonicalPath()); try {/*from www.ja va 2 s.co m*/ // This is a temporary fix until the yamj3.home can be read from the servlet ClassTools.checkSystemProperty("yamj3.home", (new File(yamjHome)).getCanonicalPath()); } catch (IOException ex) { ClassTools.checkSystemProperty("yamj3.home", yamjHome); } YamjInfo yi = new YamjInfo(FileScanner.class); yi.printHeader(LOG); CmdLineParser parser = getCmdLineParser(); ExitType status; try { parser.parse(args); if (parser.userWantsHelp()) { help(parser); status = SUCCESS; } else { FileScanner main = new FileScanner(); status = main.execute(parser); } } catch (CmdLineException ex) { LOG.error("Failed to parse command line options: {}", ex.getMessage()); help(parser); status = CMDLINE_ERROR; } System.exit(status.getReturn()); }
From source file:com.devbury.desktoplib.systemtray.SystemTrayApplication.java
public static void main(String[] args) { String appHome = System.getenv("APP_HOME"); System.out.println("app home is " + appHome); if (appHome != null) { System.setProperty("app.home", appHome); }// w w w. j ava 2s.c o m SystemTrayApplication sta = newSystemTrayApplication(); sta.setArgs(args); sta.configureLogging(); sta.start(); }
From source file:com.tencent.jflynn.doc.SwaggerMain.java
public static void main(String[] args) throws Exception { System.setProperty("CONFIG_MODE", "DEV"); SpringApplication.run(SwaggerMain.class, args); }
From source file:com.sm.store.server.ClusterServer.java
public static void main(String[] args) { String[] opts = new String[] { "-host", "-configPath", "-dataPath", "-port", "replicaPort", "-start", "-freq" }; String[] defaults = new String[] { "", "", "", "0", "0", "true", "0" }; String[] paras = getOpts(args, opts, defaults); String configPath = paras[1]; if (configPath.length() == 0) { logger.error("missing config path"); throw new RuntimeException("missing -configPath"); }//from ww w . ja v a 2s . c o m //set configPath to system properties System.setProperty("configPath", configPath); NodeConfig nodeConfig = getNodeConfig(configPath + "/node.properties"); //int clusterNo = Integer.valueOf( paras[0]); String dataPath = paras[2]; if (dataPath.length() == 0) { dataPath = "./data"; } int port = Integer.valueOf(paras[3]); int replicaPort = Integer.valueOf(paras[4]); //get from command line, if not form nodeConfig if (port == 0) port = nodeConfig.getPort(); if (port == 0) { throw new RuntimeException("port is 0"); } else { if (replicaPort == 0) replicaPort = port + 1; } boolean start = Boolean.valueOf(paras[5]); String host = paras[0]; //get from command line, if not form nodeConfig or from getHost if (host.length() == 0) host = nodeConfig.getHost(); if (host.length() == 0) host = getLocalHost(); int freq = Integer.valueOf(paras[6]); logger.info("read clusterNode and storeConfig from " + configPath); BuildClusterNodes bcn = new BuildClusterNodes(configPath + "/clusters.xml"); //BuildStoreConfig bsc = new BuildStoreConfig(configPath+"/stores.xml"); BuildRemoteConfig brc = new BuildRemoteConfig(configPath + "/stores.xml"); List<ClusterNodes> clusterNodesList = bcn.build(); short clusterNo = findClusterNo(host + ":" + port, clusterNodesList); logger.info("create cluster server config for cluster " + clusterNo + " host " + host + " port " + port + " replica port " + replicaPort); ClusterServerConfig serverConfig = new ClusterServerConfig(clusterNodesList, brc.build().getConfigList(), clusterNo, dataPath, configPath, port, replicaPort, host); //over write config from command line if freq > 0 if (freq > 0) serverConfig.setFreq(freq); logger.info("create cluster server"); ClusterStoreServer cs = new ClusterStoreServer(serverConfig, new HessianSerializer()); // start replica server cs.startReplicaServer(); logger.info("hookup jvm shutdown process"); cs.hookShutdown(); if (start) { logger.info("server is starting " + cs.getServerConfig().toString()); cs.start(); } else logger.warn("server is staged and wait to be started"); List list = new ArrayList(); //add jmx metric List<String> stores = cs.getAllStoreNames(); for (String store : stores) { list.add(cs.getStore(store)); } list.add(cs); stores.add("ClusterServer"); JmxService jms = new JmxService(list, stores); }
From source file:com.mycompany.kerberosbyip.NewMain.java
public static void main(String[] args) throws Exception { Logger logger = Logger.getLogger("org.apache.http"); logger.setLevel(Level.TRACE); System.setProperty("sun.security.krb5.debug", "true"); System.setProperty("java.security.krb5.realm", REALM); System.setProperty("java.security.krb5.kdc", KDC); ClassLoader classLoader = NewMain.class.getClassLoader(); URL loginConf = classLoader.getResource("login.conf"); System.setProperty("java.security.auth.login.config", loginConf.toString()); NewMain m = new NewMain(); m.runPrivileged();//www.jav a 2 s. co m }
From source file:com.sm.store.server.grizzly.GZClusterServer.java
public static void main(String[] args) { String[] opts = new String[] { "-host", "-configPath", "-dataPath", "-port", "replicaPort", "-start", "-freq" }; String[] defaults = new String[] { "", "", "", "0", "0", "true", "10" }; String[] paras = getOpts(args, opts, defaults); String configPath = paras[1]; if (configPath.length() == 0) { logger.error("missing config path"); throw new RuntimeException("missing -configPath"); }/*from ww w .ja v a 2s . co m*/ System.setProperty("configPath", configPath); NodeConfig nodeConfig = getNodeConfig(configPath + "/node.properties"); //int clusterNo = Integer.valueOf( paras[0]); String dataPath = paras[2]; if (dataPath.length() == 0) { dataPath = "./data"; } int port = Integer.valueOf(paras[3]); int replicaPort = Integer.valueOf(paras[4]); //get from command line, if not form nodeConfig if (port == 0) port = nodeConfig.getPort(); if (port == 0) { throw new RuntimeException("port is 0"); } else { if (replicaPort == 0) replicaPort = port + 1; } boolean start = Boolean.valueOf(paras[5]); String host = paras[0]; //get from command line, if not form nodeConfig or from getHost if (host.length() == 0) host = nodeConfig.getHost(); if (host.length() == 0) host = getLocalHost(); int freq = Integer.valueOf(paras[6]); logger.info("read clusterNode and storeConfig from " + configPath); BuildClusterNodes bcn = new BuildClusterNodes(configPath + "/clusters.xml"); //BuildStoreConfig bsc = new BuildStoreConfig(configPath+"/stores.xml"); BuildRemoteConfig brc = new BuildRemoteConfig(configPath + "/stores.xml"); List<ClusterNodes> clusterNodesList = bcn.build(); short clusterNo = findClusterNo(host + ":" + port, clusterNodesList); logger.info("create cluster server config for cluster " + clusterNo + " host " + host + " port " + port + " replica port " + replicaPort); ClusterServerConfig serverConfig = new ClusterServerConfig(clusterNodesList, brc.build().getConfigList(), clusterNo, dataPath, configPath, port, replicaPort, host); serverConfig.setFreq(freq); logger.info("create cluster server"); GZClusterStoreServer cs = new GZClusterStoreServer(serverConfig, new HessianSerializer()); // start replica server cs.startReplicaServer(); logger.info("hookup jvm shutdown process"); cs.hookShutdown(); if (start) { logger.info("server is starting " + cs.getServerConfig().toString()); cs.start(); } else logger.warn("server is staged and wait to be started"); List list = new ArrayList(); //add jmx metric List<String> stores = cs.getAllStoreNames(); for (String store : stores) { list.add(cs.getStore(store)); } list.add(cs); stores.add("ClusterServer"); JmxService jms = new JmxService(list, stores); try { logger.info("Read from console and wait ...."); int c = System.in.read(); } catch (IOException e) { logger.warn("Error reading " + e.getMessage()); } logger.warn("Exiting from System.in.read()"); }
From source file:MainClass.java
public static void main(String[] arguments) { String home, system;//from w w w .ja va 2 s . c o m home = System.getProperty("user.home", "."); system = home + File.separatorChar + ".database"; System.setProperty("derby.system.home", system); createDatabase(); readDatabase(); }
From source file:com.turbospaces.api.EmbeddedJSpaceRunner.java
/** * launcher method/*from w w w. ja va 2 s. c o 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(); }