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:com.discursive.jccook.httpclient.DebuggingExample.java

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

    // Configure Logging
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    HttpClient client = new HttpClient();
    String url = "http://www.discursive.com/jccook/";
    HttpMethod method = new GetMethod(url);
    client.executeMethod(method);/*from  w w  w  .j  a v a  2  s  .  c  o  m*/
    String response = method.getResponseBodyAsString();

    System.out.println(response);
    method.releaseConnection();
    method.recycle();
}

From source file:StreamTaggerDemo.java

public static void main(String args[]) {
    try {/*from  w  w  w.  j  a  va2  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 StreamTaggerDemo <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.xml";
        // StreamTagger tagger = new StreamTagger((Reader) br, confPath);
        StreamTagger tagger = new StreamTagger((Reader) br);

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

        while (tagger.hasNext()) {
            Token token = tagger.next();
            System.out.println(token.toString() + "\t(" + token.getBasicString() + ")" + "\t" + token.getPos()
                    + "(" + token.start() + "," + token.end() + "," + token.length() + ")\t"
                    + token.getReading() + "\t" + token.getPronunciation());
        }

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

From source file:com.discursive.jccook.httpclient.RedirectExample.java

public static void main(String[] args) throws HttpException, IOException {
    // Configure Logging
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    HttpClient client = new HttpClient();
    String url = "http://www.discursive.com/cgi-bin/jccook/redirect.cgi";

    System.out.println("Executing Method not following redirects: ");
    HttpMethod method = new GetMethod(url);
    method.setFollowRedirects(false);//  ww  w  . j  a v a  2  s . co  m
    executeMethod(client, method);

    System.out.println("Executing Method following redirects: ");
    method = new GetMethod(url);
    method.setFollowRedirects(true);
    executeMethod(client, method);
}

From source file:com.discursive.jccook.httpclient.PostExample.java

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

    // Configure Logging
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    HttpClient client = new HttpClient();

    // Create POST method
    String weblintURL = "http://www.discursive.com/cgi-bin/jccook/param_list.cgi";
    PostMethod method = new PostMethod(weblintURL);

    // Set parameters on POST   
    method.setParameter("test1", "Hello World");
    method.addParameter("test2", "This is a Form Submission");
    method.addParameter("Blah", "Whoop");
    method.addParameter(new NameValuePair("Blah", "Whoop2"));

    // Execute and print response
    client.executeMethod(method);//from w  w  w .j a va  2  s. c  o m
    String response = method.getResponseBodyAsString();
    System.out.println(response);

    method.releaseConnection();
}

From source file:com.discursive.jccook.httpclient.PostFileExample.java

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

    // Configure Logging
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    HttpClient client = new HttpClient();

    // Create POST method
    String weblintURL = "http://ats.nist.gov/cgi-bin/cgi.tcl/echo.cgi";
    PostMethod method = new PostMethod(weblintURL);

    File file = new File("project.xml");
    method.setRequestBody(new FileInputStream(file));
    method.setRequestContentLength((long) file.length());

    // Execute and print response
    client.executeMethod(method);/*from  w ww.  j a  va  2  s. c  om*/
    String response = method.getResponseBodyAsString();
    System.out.println(response);

    method.releaseConnection();
}

From source file:de.longri.cachebox3.DesktopLauncher.java

public static void main(String[] args) {

    System.setProperty("org.lwjgl.util.NoChecks", "false");

    CommandLine cmd = getCommandLine(args);

    //initialize platform bitmap factory
    AwtGraphics.init();//from  w w  w . java  2  s.c o m

    //initialize platform connector
    PlatformConnector.init(new DesktopPlatformConnector());

    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
    config.resizable = false;
    config.useHDPI = true;
    config.samples = 10;
    config.width = 223;
    config.height = 397;
    config.title = "Cachebox 3.0";

    config.stencil = 8;
    config.foregroundFPS = 30;
    config.backgroundFPS = 10;

    if (cmd.hasOption("note")) {
        //force note 4 layout
        config.width = 323;
        config.height = 574;
    }

    if (cmd.hasOption("scale")) {
        String value = cmd.getOptionValue("scale");
        float scale = Float.parseFloat(value);
        CB.setGlobalScale(scale);
        config.width *= scale;
        config.height *= scale;
    }

    if (cmd.hasOption("gps")) {
        JFrame f;
        try {
            f = SimulatorMain.createFrame();
            f.pack();
            f.setResizable(false);
            f.setVisible(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    initVtm();

    // Don't change this LogLevel
    // Cachebox use the slf4j implematation for LibGdx as Log engine.
    // so set LogLevel on CB.class if you wont (USED_LOG_LEVEL)
    new LwjglApplication(new CacheboxMain(), config).setLogLevel(LwjglApplication.LOG_DEBUG);
}

From source file:com.discursive.jccook.httpclient.MultipartPostFileExample.java

public static void main(String[] args) throws HttpException, IOException {
    // Configure Logging
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    HttpClient client = new HttpClient();

    // Create POST method
    String weblintURL = "http://ats.nist.gov/cgi-bin/cgi.tcl/echo.cgi";
    MultipartPostMethod method = new MultipartPostMethod(weblintURL);

    File file = new File("data", "test.txt");
    File file2 = new File("data", "sample.txt");
    method.addParameter("test.txt", file);
    method.addPart(new FilePart("sample.txt", file2, "text/plain", "ISO-8859-1"));

    // Execute and print response
    client.executeMethod(method);/*from  ww w  .jav a  2 s  .  co m*/
    String response = method.getResponseBodyAsString();
    System.out.println(response);

    method.releaseConnection();
}

From source file:com.sundy.SpringBootRpcClientDemo.java

public static void main(String[] args) {
    System.setProperty("server.port", "8082");
    SpringApplication.run(SpringBootRpcClientDemo.class, args);
    System.out.println("client start...");
}

From source file:com.comcast.cdn.traffic_control.traffic_router.core.TrafficRouterStart.java

public static void main(String[] args) throws Exception {
    System.setProperty("deploy.dir", "src/test");
    System.setProperty("dns.zones.dir", "src/test/var/auto-zones");

    LogManager.getLogger("org.eclipse.jetty").setLevel(Level.WARN);
    LogManager.getLogger("org.springframework").setLevel(Level.WARN);

    ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout("%d{ISO8601} [%-5p] %c{4}: %m%n"));
    LogManager.getRootLogger().addAppender(consoleAppender);
    LogManager.getRootLogger().setLevel(Level.INFO);

    File webAppDirectory = new File("src/main/webapp");
    if (!webAppDirectory.exists()) {
        LogManager.getRootLogger().fatal(webAppDirectory.getAbsolutePath()
                + " does not exist, are you running TrafficRouterStart from the correct directory?");
        System.exit(1);/*from www  .  j av a2s  . co m*/
    }

    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8081);
    server.addConnector(connector);

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    server.setHandler(bb);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:Snippet154.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);

    /*/*from w  ww.jav  a 2s .  co 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();
}