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:MyTerrierClass.java

public static void main(String[] args) throws InterruptedException, IOException {

    System.gc();/* ww  w.j  a  v a  2s  .com*/
    System.setProperty("terrier.home", "/home/manan/Downloads/terrier-4.0");
    System.setProperty("terrier.etc", "/home/manan/Downloads/terrier-4.0/etc");
    System.setProperty("terrier.setup", "/home/manan/Downloads/terrier-4.0/etc/terrier.properties");

    bw = new BufferedWriter(new FileWriter("/home/manan/terrier_trials/myOutput.txt", false));
    bw.write("#######OUTPUT#######");

    List<String> cl = new ArrayList<>();
    cl.add("/home/manan/wiki-small/");
    SimpleFileCollection sf = new SimpleFileCollection(cl, true);

    print("sf list size b4 indexing:" + sf.getFileList().size());

    Indexer indexer = new BlockIndexer("/home/manan/terrier_trials/", ".trial");
    indexer.index(new Collection[] { sf });

    print("sf list size after indexing:" + sf.getFileList().size());
    sf.reset();
    //get document reader
    Reader reader = sf.next().getReader();
    //print all tokens
    Tokeniser tokeniser = Tokeniser.getTokeniser();
    TokenStream ts = tokeniser.tokenise(reader);
    while (ts.hasNext()) {
        System.out.println(ts.next());
    }

    //        Index index = Index.createIndex();
    //        
    //        Manager queryingManager = new Manager(index);
    // 
    //        String query = "name quick";
    //        SearchRequest srq = queryingManager.newSearchRequest("queryID0", query);
    //        srq.addMatchingModel("Matching", "PL2");
    //        queryingManager.runPreProcessing(srq);
    //        queryingManager.runMatching(srq);
    //        queryingManager.runPostProcessing(srq);
    //        queryingManager.runPostFilters(srq);
    //        ResultSet rs = srq.getResultSet();
    //        for(int each : rs.getDocids())
    //            System.out.println("docids: "+ each);

    //        Index index = Index.createIndex();
    //        Lexicon<String> lex = index.getLexicon();
    //        print("lex number of entries: "+lex.numberOfEntries());
    //        String myTerm = "name";
    //        LexiconEntry le = lex.getLexiconEntry(myTerm);
    //        if(le!=null)
    //        {
    //            print(myTerm+" in number of docs: "+le.getDocumentFrequency());
    //            print(myTerm+" occurance times: "+le.getFrequency());
    //        }
    //        else
    //        {
    //            print(myTerm+" not found");
    //        }

    //        Index index = Index.createIndex();
    //        BitPostingIndex inv = (BitPostingIndex) index.getInvertedIndex();
    //        MetaIndex meta = index.getMetaIndex();
    //        Lexicon<String> lex = index.getLexicon();
    //        LexiconEntry le = lex.getLexiconEntry( "name" );
    //        IterablePosting postings = inv.getPostings((BitIndexPointer) le);
    //        while (postings.next() != IterablePosting.EOL) {
    //                String docno = meta.getItem("docno", postings.getId());
    //                System.out.println(docno + " with frequency " + postings.getFrequency());
    //        }

    bw.close();
}

From source file:com.ahanda.techops.noty.clientTest.Client.java

public static void main(String[] args) throws Exception {
    if (args.length == 1) {
        System.setProperty("PINT.conf", args[0]);
    }/*from  ww w.j a  va2 s. co m*/

    if (System.getProperty("PINT.conf") == null)
        throw new IllegalArgumentException();

    JsonNode config = null;
    Config cf = Config.getInstance();
    cf.setupConfig();

    String scheme = "http";
    String host = cf.getHttpHost();
    int port = cf.getHttpPort();

    if (port == -1) {
        port = 8080;
    }

    if (!"http".equalsIgnoreCase(scheme)) {
        l.warn("Only HTTP is supported.");
        return;
    }

    // Configure SSL context if necessary.
    final boolean ssl = "https".equalsIgnoreCase(scheme);
    final SslContext sslCtx;
    if (ssl) {
        sslCtx = SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE);
    } else {
        sslCtx = null;
    }

    // Configure the client.
    EventLoopGroup group = new NioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        b.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
            @Override
            protected void initChannel(SocketChannel ch) throws Exception {
                ChannelPipeline p = ch.pipeline();
                p.addLast(new HttpClientCodec());
                // p.addLast( "decoder", new HttpResponseDecoder());
                // p.addLast( "encoder", new HttpRequestEncoder());

                // Remove the following line if you don't want automatic content decompression.
                // p.addLast(new HttpContentDecompressor());

                // Uncomment the following line if you don't want to handle HttpContents.
                p.addLast(new HttpObjectAggregator(10485760));

                p.addLast(new ClientHandler());
            }
        });

        // Make the connection attempt.
        Channel ch = b.connect(host, port).sync().channel();

        ClientHandler client = new ClientHandler();
        client.login(ch, ClientHandler.credential);
        // ClientHandler.pubEvent( ch, ClientHandler.event );

        // Wait for the server to close the connection.
        ch.closeFuture().sync();
        l.info("Closing Client side Connection !!!");
    } finally {
        // Shut down executor threads to exit.
        group.shutdownGracefully();
    }
}

From source file:com.aliyun.openservices.odps.console.ODPSConsole.java

public static void main(String[] args) throws ODPSConsoleException {

    List<String> options = new ArrayList<String>();
    // ?confignull
    String config = prepareOptions(args, options);

    // session context
    ExecutionContext sessionContext = ExecutionContext.load(config);

    checkSDKEnviron();// ww  w  .  ja va  2s  . c  om

    DefaultOutputWriter writer = sessionContext.getOutputWriter();

    writer.writeDebug("ODPSConsole Start");
    try {

        // apache.commons.logging???
        System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");

        // sessionContextcommand
        // ??command????
        AbstractCommand oa = CommandParserUtils.parseOptions(
                config == null ? args : (String[]) options.toArray(new String[0]), sessionContext);

        oa.run();
    } catch (OdpsException e) {
        writer.writeError(ODPSConsoleConstants.FAILED_MESSAGE + e.getMessage());
        // debug??stack?
        writer.writeDebug(StringUtils.stringifyException(e));

        System.exit(1);
    } catch (ODPSConsoleException e) {
        writer.writeError(ODPSConsoleConstants.FAILED_MESSAGE + e.getMessage());
        writer.writeDebug(StringUtils.stringifyException(e));

        System.exit(e.getExitCode());
    } catch (Exception e) {
        // ,
        e.printStackTrace();

        System.exit(1);
    }

    sessionContext.getOutputWriter().writeDebug("ODPSConsole End");
    // 
    System.exit(0);
}

From source file:com.haulmont.cuba.core.sys.utils.DbUpdaterUtil.java

public static void main(String[] args) {
    String property = System.getProperty("logback.configurationFile");
    if (StringUtils.isBlank(property)) {
        System.setProperty("logback.configurationFile", "com/haulmont/cuba/core/sys/utils/dbutil-logback.xml");
    }/*from  ww w . j  a  v a2 s.c  o m*/

    DbUpdaterUtil runner = new DbUpdaterUtil();
    runner.execute(args);
}

From source file:MyViewChooser.java

public static void main(String args[]) {
    System.setProperty("swing.defaultlaf", "javax.swing.plaf.metal.MetalLookAndFeel");
    MyViewChooser vc = new MyViewChooser();
    vc.setVisible(true);//from ww w .j  a  v a2 s.  c o m
}

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/*  ww  w .j ava 2s .  c  om*/

    // 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:org.soasecurity.wso2.mutual.auth.oauth2.client.MutualSSLOAuthClient.java

public static void main(String[] args) throws Exception {

    File file = new File((new File(".")).getCanonicalPath() + File.separator + "src" + File.separator + "main"
            + File.separator + "resources" + File.separator + "keystore" + File.separator + keyStoreName);

    if (!file.exists()) {
        throw new Exception("Key Store file can not be found in " + file.getCanonicalPath());
    }/*from www.j  a  va 2s .c  o m*/

    //Set trust store, you need to import server's certificate of CA certificate chain in to this
    //key store
    System.setProperty("javax.net.ssl.trustStore", file.getCanonicalPath());
    System.setProperty("javax.net.ssl.trustStorePassword", keyStorePassword);

    //Set key store, this must contain the user private key
    //here we have use both trust store and key store as the same key store
    //But you can use a separate key store for key store an trust store.
    System.setProperty("javax.net.ssl.keyStore", file.getCanonicalPath());
    System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);

    HttpClient client = new HttpClient();

    HttpMethod method = new PostMethod(endPoint);

    // Base64 encoded client id & secret
    method.setRequestHeader("Authorization",
            "Basic T09pN2dpUjUwdDZtUmU1ZkpmWUhVelhVa1QwYTpOOUI2dDZxQ0E2RFp2eTJPQkFIWDhjVlI1eUlh");
    method.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    NameValuePair pair1 = new NameValuePair();
    pair1.setName("grant_type");
    pair1.setValue("x509");

    NameValuePair pair2 = new NameValuePair();
    pair2.setName("username");
    pair2.setValue("asela");

    NameValuePair pair3 = new NameValuePair();
    pair3.setName("password");
    pair3.setValue("asela");

    method.setQueryString(new NameValuePair[] { pair1, pair2, pair3 });

    int statusCode = client.executeMethod(method);

    if (statusCode != HttpStatus.SC_OK) {

        System.out.println("Failed: " + method.getStatusLine());

    } else {

        byte[] responseBody = method.getResponseBody();

        System.out.println(new String(responseBody));
    }
}

From source file:ProcessorDemo.java

public static void main(String args[]) {
    try {//from  www. java2  s. c  o  m
        System.setProperty("sen.home", "../Sen1221/senhome-ipadic");
        System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
        System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "FATAL");

        if (args.length != 2) {
            System.err.println("usage: java ProcessorDemo <filename> <encoding>");
            System.exit(1);
        }

        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), args[1]));
        String confPath = System.getProperty("sen.home") + System.getProperty("file.separator")
                + "conf/sen-processor.xml";
        StreamTagger tagger = new StreamTagger((Reader) br, confPath);
        readConfig(confPath);

        if (!isCompound) {
            CompoundWordPostProcessor cwProcessor = new CompoundWordPostProcessor(compoundFile);
            tagger.addPostProcessor(cwProcessor);
        }

        if (compositRule != null && !compositRule.equals("")) {
            CompositPostProcessor processor = new CompositPostProcessor();
            processor.readRules(new BufferedReader(new StringReader(compositRule)));
            tagger.addPostProcessor(processor);
        }

        if (remarkRule != null && !remarkRule.equals("")) {
            RemarkPreProcessor processor = new RemarkPreProcessor();
            processor.readRules(new BufferedReader(new StringReader(remarkRule)));
            tagger.addPreProcessor(processor);
            RemarkPostProcessor p2 = new RemarkPostProcessor();
            tagger.addPostProcessor(p2);
        }

        // BufferedReader is = new BufferedReader(System.in);

        while (tagger.hasNext()) {
            Token token = tagger.next();
            System.out.println(token.getSurface() + "\t" + token.getPos() + "\t" + token.start() + "\t"
                    + token.end() + "\t" + token.getCost() + "\t" + token.getAddInfo());
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:it.polimi.tower4clouds.data_analyzer.DAServer.java

public static void main(String[] args) {
    PropertiesConfiguration releaseProperties = null;
    try {/*from w  w  w.  j a v  a 2 s.c o m*/
        releaseProperties = new PropertiesConfiguration("release.properties");
    } catch (org.apache.commons.configuration.ConfigurationException e) {
        logger.error("Internal error", e);
        System.exit(1);
    }
    APP_NAME = releaseProperties.getString("application.name");
    APP_FILE_NAME = releaseProperties.getString("dist.file.name");
    APP_VERSION = releaseProperties.getString("release.version");
    try {
        DAConfig config = new DAConfig(args, APP_FILE_NAME);
        if (config.isHelp()) {
            System.out.println(config.usage);
        } else if (config.isVersion()) {
            System.out.println("Version: " + APP_VERSION);
        } else {
            String[] rspArgs = new String[1];
            rspArgs[0] = "da.properties";
            System.setProperty(InputDataUnmarshaller.INPUT_DATA_UNMARSHALLER_IMPL_PROPERTY_NAME,
                    DAInputDataUnmarshaller.class.getName());
            System.setProperty(OutputDataMarshaller.OUTPUT_DATA_MARSHALLER_IMPL_PROPERTY_NAME,
                    DAOutputDataMarshaller.class.getName());
            System.setProperty("log4j.configuration", "log4j.properties");
            //            System.setProperty("rsp_server.static_resources.path",
            //                  config.getKBFolder()); NOT USED BY RSP!!!
            System.setProperty("csparql_server.port", Integer.toString(config.getPort()));
            logger.info("{} {}", APP_NAME, APP_VERSION);
            rsp_services_csparql_server.main(rspArgs);
        }
    } catch (ConfigurationException e) {
        logger.error("Configuration problem: " + e.getMessage());
        logger.error("Run \"" + APP_FILE_NAME + " -help\" for help");
        System.exit(1);
    } catch (Exception e) {
        logger.error("Unknown error", e);
    }
}

From source file:DOM3.java

public static void main(String[] argv) {

    if (argv.length == 0) {
        printUsage();//from  w w w  .j av a2 s. c om
        System.exit(1);
    }

    try {

        // get DOM Implementation using DOM Registry
        System.setProperty(DOMImplementationRegistry.PROPERTY,
                "org.apache.xerces.dom.DOMXSImplementationSourceImpl");
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();

        DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");

        // create DOMBuilder
        builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

        DOMConfiguration config = builder.getDomConfig();

        // create Error Handler
        DOMErrorHandler errorHandler = new DOM3();

        // create filter
        LSParserFilter filter = new DOM3();

        builder.setFilter(filter);

        // set error handler
        config.setParameter("error-handler", errorHandler);

        // set validation feature
        // config.setParameter("validate", Boolean.FALSE);
        config.setParameter("validate", Boolean.TRUE);

        // set schema language
        config.setParameter("schema-type", "http://www.w3.org/2001/XMLSchema");
        // config.setParameter("psvi",Boolean.TRUE);
        // config.setParameter("schema-type","http://www.w3.org/TR/REC-xml");

        // set schema location
        config.setParameter("schema-location", "personal.xsd");

        // parse document
        System.out.println("Parsing " + argv[0] + "...");
        Document doc = builder.parseURI(argv[0]);

        // set error handler on the Document
        config = doc.getDomConfig();

        config.setParameter("error-handler", errorHandler);

        // set validation feature
        config.setParameter("validate", Boolean.TRUE);
        config.setParameter("schema-type", "http://www.w3.org/2001/XMLSchema");
        // config.setParameter("schema-type","http://www.w3.org/TR/REC-xml");
        config.setParameter("schema-location", "data/personal.xsd");

        // remove comments from the document
        config.setParameter("comments", Boolean.FALSE);

        System.out.println("Normalizing document... ");
        doc.normalizeDocument();

        // create DOMWriter
        LSSerializer domWriter = impl.createLSSerializer();

        System.out.println("Serializing document... ");
        config = domWriter.getDomConfig();
        config.setParameter("xml-declaration", Boolean.FALSE);
        // config.setParameter("validate",errorHandler);

        // serialize document to standard output
        // domWriter.writeNode(System.out, doc);
        LSOutput dOut = impl.createLSOutput();
        dOut.setByteStream(System.out);
        domWriter.write(doc, dOut);

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}