Example usage for java.lang System setProperty

List of usage examples for java.lang System setProperty

Introduction

In this page you can find the example usage for java.lang System setProperty.

Prototype

public static String setProperty(String key, String value) 

Source Link

Document

Sets the system property indicated by the specified key.

Usage

From source file:edu.harvard.i2b2.previousquery.QueryC.java

public static void main(String[] args) {
    final String ssFakeApplicationConfigurationXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
            + "<contents>\r\n" + "    <table>\r\n" + "        <name>Demographics</name>\r\n"
            + "        <tableName>Demographics</tableName>\r\n" + "        <status/>\r\n"
            + "        <description/>\r\n" + "        <lookupDB>metadata</lookupDB>\r\n"
            + "        <webserviceName>http://phsi2b2appprod1.mgh.harvard.edu:8080/i2b2/services/Select</webserviceName>\r\n"
            + "    </table>\r\n" + "    <table>\r\n" + "        <name>Diagnoses</name>\r\n"
            + "        <tableName>Diagnoses</tableName>\r\n" + "        <status/>\r\n"
            + "        <description/>\r\n" + "        <lookupDB>metadata</lookupDB>\r\n"
            + "        <webserviceName>http://phsi2b2appprod1.mgh.harvard.edu:8080/i2b2/services/Select</webserviceName>\r\n"
            + "    </table>\r\n" + "    <table>\r\n" + "        <name>Medications</name>\r\n"
            + "        <tableName>Medications</tableName>\r\n" + "        <status/>\r\n"
            + "        <description/>\r\n" + "        <lookupDB>metadata</lookupDB>\r\n"
            + "        <webserviceName>http://phsi2b2appprod1.mgh.harvard.edu:8080/i2b2/services/Select</webserviceName>\r\n"
            + "    </table>\r\n" + "    <table>\r\n" + "        <name>I2B2</name>\r\n"
            + "        <tableName>i2b2</tableName>\r\n" + "        <status/>\r\n" + "        <description/>\r\n"
            + "        <lookupDB>metadata</lookupDB>\r\n"
            + "        <webserviceName>http://phsi2b2appprod1.mgh.harvard.edu:8080/i2b2/services/Select</webserviceName>\r\n"
            + "    </table>\r\n" + "</contents>";
    System.setProperty("ApplicationConfigurationXML", ssFakeApplicationConfigurationXML);
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout(SWT.HORIZONTAL));
    shell.setText("ExplorerC Test");
    shell.setSize(1000, 800);//  w  w w  . j a  v a2s.co  m
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:com.cic.datacrawl.ui.Main.java

/**
 * Main entry point. Creates a debugger attached to a Rhino
 * {@link com.cic.datacrawl.ui.shell.Shell} shell session.
 *//*from  w  ww  .  ja v a  2s  .co  m*/
public static void main(final String[] args) {
    if (System.getProperties().get("os.name").toString().toLowerCase().indexOf("linux") >= 0)
        System.setProperty("sun.awt.xembedserver", "true");
    try {
        String path = null;
        boolean reflash = true;
        if (args != null && args.length > 0) {
            if (args[0].equalsIgnoreCase("-h")) {
                System.out.println("Command Format: \n" + "\t%JAVA_HOME%\\BIN\\JAVA -jar homepageCatcher.jar "
                        + "[-d config path]\n" + "\t%JAVA_HOME%\\BIN\\JAVA -jar homepageCatcher.jar "
                        + "[-d config path_1;path_2;....;path_n]\n");
            }

            int pathIndex = ArrayUtils.indexOf(args, "-d");
            if (pathIndex >= 0) {
                try {
                    path = args[pathIndex + 1];
                    File f = new File(path);
                    if (!f.exists()) {
                        LOG.warn("Invalid path of configuration. " + "Using default configuration.");
                    }
                } catch (Throwable e) {
                    LOG.warn("Invalid path of configuration. " + "Using default configuration.");
                }
            }
            // int reflashIndex = ArrayUtils.indexOf(args, "-r");
            //
            // reflash = new Boolean(args[reflashIndex + 1]).booleanValue();
        }
        if (path == null || path.trim().length() == 0)
            path = Config.INSTALL_PATH + File.separator + "config" + File.separator + "beans";

        LOG.debug("Config Path: \"" + path + "\"");
        // ?IOC
        // ????
        // ?
        ApplicationContext.initialiaze(path, reflash);
        System.setProperty(ApplicationContext.CONFIG_PATH, path);
        // js???
        InitializerRegister.getInstance().execute();
        // ???
        //VerifyCodeInputDialog.init();
        // ??
        //initTestData();
        // ?GUI
        Thread thread = new Thread(new Runnable() {

            @Override
            public void run() {
                startupGUI(args);
            }
        });
        thread.setName("UI_Thread");
        thread.start();

    } catch (Throwable e) {
        LOG.error(e.getMessage(), e);
    }
}

From source file:Main.java

public static void setUseSaxonTransformFactory() {
    if (System.getProperty(XSLT_TRANSFORMER_FACTORY) == null) {
        System.setProperty(XSLT_TRANSFORMER_FACTORY, SAXON_TRANSFORMER_FACTORY);
    } else {//w  ww  .  j  av  a 2 s  .com
        throw new IllegalStateException(XSLT_TRANSFORMER_FACTORY + " is already set");
    }
}

From source file:Main.java

public static DocumentBuilder getJaxpDocBuilder() {
    try {//from  ww w . j  ava 2 s . c  o m
        synchronized (jaxpLock) {
            System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                    "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
            System.setProperty("javax.xml.parsers.SaxParserFactory",
                    "org.apache.xerces.jaxp.SAXParserFactoryImpl");
            DocumentBuilderFactory docBuildFactory = DocumentBuilderFactory.newInstance();
            docBuildFactory.setAttribute("http://apache.org/xml/features/dom/defer-node-expansion",
                    Boolean.FALSE);
            docBuildFactory.setNamespaceAware(true);
            docBuildFactory.setValidating(false);
            return docBuildFactory.newDocumentBuilder();
        }
    } catch (ParserConfigurationException pce) {
        throw new RuntimeException(pce.getMessage());
    }
}

From source file:Main.java

/**
 * A bug in Android OS prior to Froyo forbids the usage of http.keepAlive as closing a
 * connection input stream would poison the connection pool.
 *//*from w ww.j  av a2s.c o m*/
static void disableConnectionReuseIfNecessary() {
    // HTTP connection reuse which was buggy pre-froyo
    if (Integer.parseInt(Build.VERSION.SDK) < 8) {
        System.setProperty("http.keepAlive", "false");
    }
}

From source file:Main.java

/**
 * Workaround for bug pre-Froyo, see here for more info:
 * http://android-developers.blogspot.com/2011/09/androids-http-clients.html
 *///w w  w. ja  va 2 s  .  c  o  m
public static void disableConnectionReuseIfNecessary() {
    // HTTP connection reuse which was buggy pre-froyo
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
        System.setProperty("http.keepAlive", "false");
    }
}

From source file:Main.java

public static String serializeNode(Node node) throws LSException, IllegalAccessException, DOMException,
        InstantiationException, ClassNotFoundException, ClassCastException {
    System.setProperty(DOMImplementationRegistry.PROPERTY, "org.apache.xerces.dom.DOMImplementationSourceImpl");
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
    LSSerializer writer = impl.createLSSerializer();
    String serializedElement = writer.writeToString(node);
    return serializedElement;
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean setProxyLollipop(final Context context, String host, int port) {
    System.setProperty("http.proxyHost", host);
    System.setProperty("http.proxyPort", port + "");
    System.setProperty("https.proxyHost", host);
    System.setProperty("https.proxyPort", port + "");
    try {/*from  w  ww .j a v a  2s . co  m*/
        Context appContext = context.getApplicationContext();
        Class applictionClass = Class.forName("android.app.Application");
        Field mLoadedApkField = applictionClass.getDeclaredField("mLoadedApk");
        mLoadedApkField.setAccessible(true);
        Object mloadedApk = mLoadedApkField.get(appContext);
        Class loadedApkClass = Class.forName("android.app.LoadedApk");
        Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers");
        mReceiversField.setAccessible(true);
        ArrayMap receivers = (ArrayMap) mReceiversField.get(mloadedApk);
        for (Object receiverMap : receivers.values()) {
            for (Object receiver : ((ArrayMap) receiverMap).keySet()) {
                Class clazz = receiver.getClass();
                if (clazz.getName().contains("ProxyChangeListener")) {
                    Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
                    Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
                    onReceiveMethod.invoke(receiver, appContext, intent);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }

    return true;
}

From source file:edu.ku.brc.specify.config.init.SpecifyDBSetupWizardFrame.java

/**
 * @param args//from   w w  w .  java  2s .  c o m
 */
public static void main(String[] args) {
    // Set App Name, MUST be done very first thing!
    UIRegistry.setAppName("Specify"); //$NON-NLS-1$

    try {
        ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$

    } catch (MissingResourceException ex) {
        Locale.setDefault(Locale.ENGLISH);
        UIRegistry.setResourceLocale(Locale.ENGLISH);
    }

    try {
        if (!System.getProperty("os.name").equals("Mac OS X")) {
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
        }
    } catch (Exception e) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSetupWizard.class, e);
        e.printStackTrace();
    }

    AppBase.processArgs(args);
    AppBase.setupTeeForStdErrStdOut(true, false);

    System.setProperty("appdatadir", "..");

    // Then set this
    IconManager.setApplicationClass(Specify.class);
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$

    // Load Local Prefs
    AppPreferences localPrefs = AppPreferences.getLocalPrefs();
    //try {
    //System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+(new File(UIRegistry.getAppDataDir()).getCanonicalPath())+"]");
    //} catch (IOException ex) {}

    localPrefs.setDirPath(UIRegistry.getAppDataDir());

    // Check to see if we should check for a new version
    if (localPrefs.getBoolean(VERSION_CHECK, null) == null) {
        localPrefs.putBoolean(VERSION_CHECK, true);
    }

    if (localPrefs.getBoolean(EXTRA_CHECK, null) == null) {
        localPrefs.putBoolean(EXTRA_CHECK, true);
    }

    if (UIHelper.isLinux()) {
        Specify.checkForSpecifyAppsRunning();
    }

    if (UIRegistry.isEmbedded()) {
        ProcessListUtil.checkForMySQLProcesses(new ProcessListener() {
            @Override
            public void done(PROC_STATUS status) // called on the UI thread
            {
                if (status == PROC_STATUS.eOK || status == PROC_STATUS.eFoundAndKilled) {
                    startupContinuing();
                }
            }
        });
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                startupContinuing();
            }
        });
    }
}

From source file:Main.java

private static String parseXmlDocToString(Document xmlDoc)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    // Add formatting to the xml document in case we want to save to a file
    System.setProperty(DOMImplementationRegistry.PROPERTY,
            "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
    final DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    final DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
    final LSSerializer writer = impl.createLSSerializer();
    writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); // Set this to true if the output needs to be beautified.
    writer.getDomConfig().setParameter("xml-declaration", true); // Set this to true if the declaration is needed to be outputted

    return writer.writeToString(xmlDoc);
}