List of usage examples for java.lang System setProperty
public static String setProperty(String key, String value)
From source file:dk.dbc.DevelMain.java
public static void main(String[] args) { try {//from w w w .ja va2 s . co m System.setProperty("logback.configurationFile", LOGBACK_XML); new DevelMain().run(new String[] { "server", YAML_FILE_NAME }); } catch (Exception ex) { System.err.println(ex.getMessage()); System.exit(1); } }
From source file:com.ibm.jaql.MiniCluster.java
/** * @param args/* w w w .j av a 2 s .c o m*/ */ public static void main(String[] args) throws IOException { String clusterHome = System.getProperty("hadoop.minicluster.dir"); if (clusterHome == null) { clusterHome = "./minicluster"; System.setProperty("hadoop.minicluster.dir", clusterHome); } LOG.info("hadoop.minicluster.dir=" + clusterHome); File clusterFile = new File(clusterHome); if (!clusterFile.exists()) { clusterFile.mkdirs(); } if (!clusterFile.isDirectory()) { throw new IOException("minicluster home directory must be a directory: " + clusterHome); } if (!clusterFile.canRead() || !clusterFile.canWrite()) { throw new IOException("minicluster home directory must be readable and writable: " + clusterHome); } String logDir = System.getProperty("hadoop.log.dir"); if (logDir == null) { logDir = clusterHome + File.separator + "logs"; System.setProperty("hadoop.log.dir", logDir); } File logFile = new File(logDir); if (!logFile.exists()) { logFile.mkdirs(); } String confDir = System.getProperty("hadoop.conf.override"); if (confDir == null) { confDir = clusterHome + File.separator + "conf"; System.setProperty("hadoop.conf.override", confDir); } File confFile = new File(confDir); if (!confFile.exists()) { confFile.mkdirs(); } System.out.println("starting minicluster in " + clusterHome); MiniCluster mc = new MiniCluster(args); // To find the ports in the // hdfs: search for: Web-server up at: localhost:#### // mapred: search for: mapred.JobTracker: JobTracker webserver: #### Configuration conf = mc.getConf(); System.out.println("fs.default.name: " + conf.get("fs.default.name")); System.out.println("dfs.http.address: " + conf.get("dfs.http.address")); System.out.println("mapred.job.tracker.http.address: " + conf.get("mapred.job.tracker.http.address")); boolean waitForInterrupt; try { System.out.println("press enter to end minicluster (or eof to run forever)..."); waitForInterrupt = System.in.read() < 0; // wait for any input or eof } catch (Exception e) { // something odd happened. Just shutdown. LOG.error("error reading from stdin", e); waitForInterrupt = false; } // eof means that we will wait for a kill signal while (waitForInterrupt) { System.out.println("minicluster is running until interrupted..."); try { Thread.sleep(60 * 60 * 1000); } catch (InterruptedException e) { waitForInterrupt = false; } } System.out.println("shutting down minicluster..."); try { mc.tearDown(); } catch (Exception e) { LOG.error("error while shutting down minicluster", e); } }
From source file:com.hmsinc.epicenter.tools.geocoder.FacilityGeocoder.java
/** * @param args//w w w. java 2s . c om */ @SuppressWarnings("unchecked") public static void main(String[] args) { if (args.length == 5) { System.setProperty("db.driver", args[0]); System.setProperty("db.url", args[1]); System.setProperty("db.type", args[2]); System.setProperty("db.user", args[3]); System.setProperty("db.password", args[4]); appContext = new ClassPathXmlApplicationContext(CONTEXT_FILES); final ProviderRepository providerRepository = (ProviderRepository) appContext .getBean("providerRepository"); Validate.notNull(providerRepository); final Geocoder geocoder = (Geocoder) appContext.getBean("geocoder"); Validate.notNull(geocoder); final PlatformTransactionManager tm = (PlatformTransactionManager) appContext .getBean("transactionManager"); Validate.notNull(tm); final TransactionTemplate template = new TransactionTemplate(tm); List<Facility> facilities = (List<Facility>) template.execute(new TransactionCallback() { /* * (non-Javadoc) * * @see org.springframework.transaction.support.TransactionCallback#doInTransaction(org.springframework.transaction.TransactionStatus) */ public List<Facility> doInTransaction(TransactionStatus status) { return providerRepository.getList(Facility.class); } }); for (final Facility facility : facilities) { if (facility.getGeometry() == null && facility.getAddress1() != null && facility.getCity() != null && facility.getState() != null && facility.getZipcode() != null) { template.execute(new TransactionCallbackWithoutResult() { /* * (non-Javadoc) * * @see org.springframework.transaction.support.TransactionCallbackWithoutResult#doInTransactionWithoutResult(org.springframework.transaction.TransactionStatus) */ @Override protected void doInTransactionWithoutResult(TransactionStatus status) { System.out.println(facility.toString()); final Geometry geom = geocoder.geocode(facility.getAddress1(), facility.getCity(), facility.getState(), facility.getZipcode()); if (geom != null) { facility.setGeometry(geom); providerRepository.update(facility); } } }); } } } else { usage(); } }
From source file:eu.semaine.jms.JMSLogReader.java
/** * @param args/* ww w . j a v a2 s .c o m*/ */ public static void main(String[] args) throws Exception { // Use log4j for logging: System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger"); // Configure log4j Logger.getRootLogger().setLevel(Level.DEBUG); Logger.getLogger("org.apache").setLevel(Level.INFO); PatternLayout layout = new PatternLayout("%-5p %-10c %m\n"); BasicConfigurator.configure(new ConsoleAppender(layout)); String component = "*"; String level = "*"; if (args.length > 0) component = args[0]; if (args.length > 1) level = args[1]; System.out.println("Looking for log messages in topic 'semaine.log." + component + "." + level + "'"); new JMSLogReader("semaine.log." + component + "." + level); }
From source file:com.qpark.eip.core.model.analysis.config.ModelAnalysisPersistence.java
/** * Run the spring boot application.//from w ww .j a va2 s.co m * * @param args * the arguments. */ public static void main(final String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); System.setProperty("file.encoding", "UTF-8"); SpringApplication.run(ModelAnalysisPersistence.class, args); }
From source file:de.erdesignerng.visual.ERDesigner.java
public static void main(String[] args) throws IllegalAccessException, TransformerException, IOException, ParserConfigurationException, SAXException { String theFilenameToOpen = null; if (args != null) { for (String theArgument : args) { LOGGER.info("Was called with argument :" + theArgument); }/* www. ja va2s. c om*/ // In WebStart mode or standalone, there can be two options // -open <filename> // -print <filename> if (args.length == 2) { if ("-open".equals(args[0]) || "-print".equals(args[0])) { theFilenameToOpen = args[1]; } } } // Disable D3D rendering pipeline System.setProperty("sun.java2d.d3d", "false"); //Show LOGO DefaultSplashScreen theScreen = new DefaultSplashScreen("/de/erdesignerng/splashscreen.jpg"); theScreen.setVisible(true); DataTypeIO.getInstance().loadUserTypes(); final ERDesignerMainFrame frame = new ERDesignerMainFrame(); frame.setModel(frame.createNewModel()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); try { Thread.sleep(1000); } catch (InterruptedException e) { // Just wait here :-) } theScreen.setVisible(false); frame.setVisible(true); if (StringUtils.isNotEmpty(theFilenameToOpen)) { frame.commandOpenFile(new File(theFilenameToOpen)); } }
From source file:com.app.server.node.NodeServer.java
/** * @param args/*from w w w. j a v a 2 s . com*/ */ public static void main(String[] args) { System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory"); System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming"); // TODO Auto-generated method stub new NodeServer(Integer.parseInt(args[0])).start(); try { new NodeResourceSender(args[0], deployer); } catch (Exception e) { log.error("Error in executing the NodeSender ", e); // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:Neo4JDataImporter.java
public static void main(String[] args) throws Exception { /*//from w ww . j a va 2 s . com org.neo4j.rest.read_timeout=30 org.neo4j.rest.connect_timeout=30 org.neo4j.rest.driver="neo4j-rest-graphdb/1.8.RC1" org.neo4j.rest.stream=true org.neo4j.rest.batch_transactions=false (convert transaction scope into batch-rest-operations) org.neo4j.rest.logging_filter=false (set to true if verbose request/response logging should be enabled) org.neo4j.rest.read_timeout=30 * org.neo4j.rest.connect_timeout=30 * org.neo4j.rest.driver="neo4j-rest-graphdb/1.8M07" * org.neo4j.rest.stream=true * */ System.setProperty("org.neo4j.rest.read_timeout", "30"); System.setProperty("org.neo4j.rest.connect_timeout", "30"); System.setProperty("org.neo4j.rest.driver", "neo4j-rest-graphdb/1.8.RC1"); System.setProperty("org.neo4j.rest.stream", "true"); System.setProperty("org.neo4j.rest.batch_transactions", "true"); System.setProperty("org.neo4j.rest.logging_filter", "false"); // org.springframework.data.neo4j.rest.SpringRestGraphDatabase d; ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("neo4j-spring.xml"); GraphDatabaseService graphdb = applicationContext.getBean("graphDbService", GraphDatabaseService.class); // GraphDatabaseService gds = new RestGraphDatabase("http://localhost:7474/db/data"); // GraphDatabaseService graphdb = new RestGraphDatabase("http://localhost:7474/db/data",username,password); doImport(graphdb); }
From source file:org.eclipse.swt.snippets.Snippet373.java
@SuppressWarnings("restriction") public static void main(String[] args) { System.setProperty("swt.autoScale", "quarter"); Display display = new Display(); final Image eclipse = new Image(display, filenameProvider); final Image eclipseToolBar1 = new Image(display, filenameProvider); final Image eclipseToolBar2 = new Image(display, filenameProvider); final Image eclipseTableHeader = new Image(display, filenameProvider); final Image eclipseTableItem = new Image(display, filenameProvider); final Image eclipseTree1 = new Image(display, filenameProvider); final Image eclipseTree2 = new Image(display, filenameProvider); final Image eclipseCTab1 = new Image(display, filenameProvider); final Image eclipseCTab2 = new Image(display, filenameProvider); Shell shell = new Shell(display); shell.setText("Snippet 373"); shell.setImage(eclipse);/*from ww w . ja v a 2 s . c o m*/ shell.setText("DynamicDPI @ " + DPIUtil.getDeviceZoom()); shell.setLayout(new RowLayout(SWT.VERTICAL)); shell.setLocation(100, 100); shell.setSize(500, 600); shell.addListener(SWT.ZoomChanged, new Listener() { @Override public void handleEvent(Event e) { if (display.getPrimaryMonitor().equals(shell.getMonitor())) { MessageBox box = new MessageBox(shell, SWT.PRIMARY_MODAL | SWT.OK | SWT.CANCEL); box.setText(shell.getText()); box.setMessage("DPI changed, do you want to exit & restart ?"); e.doit = (box.open() == SWT.OK); if (e.doit) { shell.close(); System.out.println("Program exit."); } } } }); // Menu Menu bar = new Menu(shell, SWT.BAR); shell.setMenuBar(bar); MenuItem fileItem = new MenuItem(bar, SWT.CASCADE); fileItem.setText("&File"); fileItem.setImage(eclipse); Menu submenu = new Menu(shell, SWT.DROP_DOWN); fileItem.setMenu(submenu); MenuItem subItem = new MenuItem(submenu, SWT.PUSH); subItem.addListener(SWT.Selection, e -> System.out.println("Select All")); subItem.setText("Select &All\tCtrl+A"); subItem.setAccelerator(SWT.MOD1 + 'A'); subItem.setImage(eclipse); // CTabFolder CTabFolder folder = new CTabFolder(shell, SWT.BORDER); for (int i = 0; i < 2; i++) { CTabItem cTabItem = new CTabItem(folder, i % 2 == 0 ? SWT.CLOSE : SWT.NONE); cTabItem.setText("Item " + i); Text textMsg = new Text(folder, SWT.MULTI); textMsg.setText("Content for Item " + i); cTabItem.setControl(textMsg); cTabItem.setImage((i % 2 == 1) ? eclipseCTab1 : eclipseCTab2); } // PerMonitorV2 setting // Label label = new Label (shell, SWT.BORDER); // label.setText("PerMonitorV2 value before:after:Error"); // Text text = new Text(shell, SWT.BORDER); // text.setText(DPIUtil.BEFORE + ":" + DPIUtil.AFTER + ":" + DPIUtil.RESULT); // Composite for Label, Button, Tool-bar Composite composite = new Composite(shell, SWT.BORDER); composite.setLayout(new RowLayout(SWT.HORIZONTAL)); // Label with Image Label label1 = new Label(composite, SWT.BORDER); label1.setImage(eclipse); // Label with text only Label label2 = new Label(composite, SWT.BORDER); label2.setText("No Image"); // Button with text + Old Image Constructor Button oldButton1 = new Button(composite, SWT.PUSH); oldButton1.setText("Old Img"); oldButton1.setImage(new Image(display, IMAGE_PATH_100)); // Button with Old Image Constructor // Button oldButton2 = new Button(composite, SWT.PUSH); // oldButton2.setImage(new Image(display, filenameProvider.getImagePath(100))); // Button with Image Button createDialog = new Button(composite, SWT.PUSH); createDialog.setText("Child Dialog"); createDialog.setImage(eclipse); createDialog.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.RESIZE); dialog.setText("Child Dialog"); RowLayout rowLayout = new RowLayout(SWT.VERTICAL); dialog.setLayout(rowLayout); Label label = new Label(dialog, SWT.BORDER); label.setImage(eclipse); Point location = shell.getLocation(); dialog.setLocation(location.x + 250, location.y + 50); dialog.pack(); dialog.open(); } }); // Toolbar with Image ToolBar toolBar = new ToolBar(composite, SWT.FLAT | SWT.BORDER); Rectangle clientArea = shell.getClientArea(); toolBar.setLocation(clientArea.x, clientArea.y); for (int i = 0; i < 2; i++) { int style = i % 2 == 1 ? SWT.DROP_DOWN : SWT.PUSH; ToolItem toolItem = new ToolItem(toolBar, style); toolItem.setImage((i % 2 == 0) ? eclipseToolBar1 : eclipseToolBar2); toolItem.setEnabled(i % 2 == 0); } toolBar.pack(); Button button = new Button(shell, SWT.PUSH); button.setText("Refresh-Current Monitor : Zoom"); Text text1 = new Text(shell, SWT.BORDER); Monitor monitor = button.getMonitor(); text1.setText("" + monitor.getZoom()); button.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Monitor monitor = button.getMonitor(); text1.setText("" + monitor.getZoom()); } }); Button button2 = new Button(shell, SWT.PUSH); button2.setText("Refresh-Both Monitors : Zoom"); Text text2 = new Text(shell, SWT.BORDER); Monitor[] monitors = display.getMonitors(); StringBuilder text2String = new StringBuilder(); for (int i = 0; i < monitors.length; i++) { text2String.append(monitors[i].getZoom() + (i < (monitors.length - 1) ? " - " : "")); } text2.setText(text2String.toString()); button2.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Monitor[] monitors = display.getMonitors(); StringBuilder text2String = new StringBuilder(); for (int i = 0; i < monitors.length; i++) { text2String.append(monitors[i].getZoom() + (i < (monitors.length - 1) ? " - " : "")); } text2.setText(text2String.toString()); } }); // Table Table table = new Table(shell, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); table.setLinesVisible(true); table.setHeaderVisible(true); String titles[] = { "Title 1" }; for (int i = 0; i < titles.length; i++) { TableColumn column = new TableColumn(table, SWT.NONE); column.setText(titles[i]); column.setImage(eclipseTableHeader); } for (int i = 0; i < 1; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText(0, "Data " + i); item.setImage(0, eclipseTableItem); } for (int i = 0; i < titles.length; i++) { table.getColumn(i).pack(); } // Tree final Tree tree = new Tree(shell, SWT.BORDER); for (int i = 0; i < 1; i++) { TreeItem iItem = new TreeItem(tree, 0); iItem.setText("TreeItem (0) -" + i); iItem.setImage(eclipseTree1); TreeItem jItem = null; for (int j = 0; j < 1; j++) { jItem = new TreeItem(iItem, 0); jItem.setText("TreeItem (1) -" + j); jItem.setImage(eclipseTree2); jItem.setExpanded(true); } tree.select(jItem); } // Shell Location Monitor primary = display.getPrimaryMonitor(); Rectangle bounds = primary.getBounds(); Rectangle rect = shell.getBounds(); int x = bounds.x + (bounds.width - rect.width) / 2; int y = bounds.y + (bounds.height - rect.height) / 2; shell.setLocation(x, y); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:bluevia.examples.MODemo.java
/** * @param args/*from w w w . j a v a 2 s .c om*/ */ public static void main(String[] args) throws IOException { BufferedReader iReader = null; String apiDataFile = "API-AccessToken.ini"; String consumer_key; String consumer_secret; String registrationId; OAuthConsumer apiConsumer = null; HttpURLConnection request = null; URL moAPIurl = null; Logger logger = Logger.getLogger("moSMSDemo.class"); int i = 0; int rc = 0; Thread mThread = Thread.currentThread(); try { System.setProperty("debug", "1"); iReader = new BufferedReader(new FileReader(apiDataFile)); // Private data: consumer info + access token info + phone info consumer_key = iReader.readLine(); consumer_secret = iReader.readLine(); registrationId = iReader.readLine(); // Set up the oAuthConsumer while (true) { try { logger.log(Level.INFO, String.format("#%d: %s\n", ++i, "Requesting messages...")); apiConsumer = new DefaultOAuthConsumer(consumer_key, consumer_secret); apiConsumer.setMessageSigner(new HmacSha1MessageSigner()); moAPIurl = new URL("https://api.bluevia.com/services/REST/SMS/inbound/" + registrationId + "/messages?version=v1&alt=json"); request = (HttpURLConnection) moAPIurl.openConnection(); request.setRequestMethod("GET"); apiConsumer.sign(request); StringBuffer doc = new StringBuffer(); BufferedReader br = null; rc = request.getResponseCode(); if (rc == HttpURLConnection.HTTP_OK) { br = new BufferedReader(new InputStreamReader(request.getInputStream())); String line = br.readLine(); while (line != null) { doc.append(line); line = br.readLine(); } System.out.printf("Output message: %s\n", doc.toString()); try { JSONObject apiResponse1 = new JSONObject(doc.toString()); String aux = apiResponse1.getString("receivedSMS"); if (aux != null) { String szMessage; String szOrigin; String szDate; JSONObject smsPool = apiResponse1.getJSONObject("receivedSMS"); JSONArray smsInfo = smsPool.optJSONArray("receivedSMS"); if (smsInfo != null) { for (i = 0; i < smsInfo.length(); i++) { szMessage = smsInfo.getJSONObject(i).getString("message"); szOrigin = smsInfo.getJSONObject(i).getJSONObject("originAddress") .getString("phoneNumber"); szDate = smsInfo.getJSONObject(i).getString("dateTime"); System.out.printf("#%d %s\n - from %s\n - message:%s\n", i, szDate, szOrigin, szMessage); } } else { JSONObject sms = smsPool.getJSONObject("receivedSMS"); szMessage = sms.getString("message"); szOrigin = sms.getJSONObject("originAddress").getString("phoneNumber"); szDate = sms.getString("dateTime"); System.out.printf("#%d %s\n - from %s\n - message:%s\n", i, szDate, szOrigin, szMessage); } } } catch (JSONException e) { System.err.println("JSON error: " + e.getMessage()); } } else if (rc == HttpURLConnection.HTTP_NO_CONTENT) System.out.printf("No content\n"); else System.err.printf("Error: %d:%s\n", rc, request.getResponseMessage()); request.disconnect(); } catch (Exception e) { System.err.println("Exception: " + e.getMessage()); } mThread.sleep(15000); } } catch (Exception e) { System.err.println("Exception: " + e.getMessage()); } }