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.da.daum.DaumOk211List.java

public static void main(String[] args) {
    DaumOk211List cfl = new DaumOk211List();

    log.warn("Logging Works");
    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");

    try {//w w  w. j av a 2  s  .co  m
        // https://msp.f-secure.com/web-test/common/test.html
        // String body =
        // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f");
        /*
         * String body = CHttpUtil.DownloadHtml(
         * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on"
         * ); System.out.println(body);
         */
        String nPage = "1";
        String p_author_id = "bluesman";
        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            STORY_DIR = args[1];
        }
        if (args.length > 2) {
            CAFE_TYPE = args[2];
        }
        if (args.length > 3) {
            BOARD_TYPE = args[3];
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
        // cfl.executeAuthorList(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.da.daum.DaumCafeOneLineList.java

public static void main(String[] args) {
    DaumCafeOneLineList cfl = new DaumCafeOneLineList();

    log.warn("Logging Works");
    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");

    try {/*from  w  ww  .j  a va  2  s. com*/
        // https://msp.f-secure.com/web-test/common/test.html
        // String body =
        // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f");
        /*
         * String body = CHttpUtil.DownloadHtml(
         * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on"
         * ); System.out.println(body);
         */
        String nPage = "1";
        String p_author_id = "";
        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            p_author_id = args[1];
        }
        if (args.length > 2) {
            STORY_DIR = args[2];
        }

        if (args.length > 3) {
            p_host_url = args[3];
            SO_URL = p_host_url;
            /*
             * host_url = "http://www."+SO_URL; photo_url =
             * "http://photo."+SO_URL+"/album/theme/"; story_url =
             * "http://story."+SO_URL+"/honor/";
             */
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
        // cfl.executeAuthorList(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.yahoo.dba.tools.myperfserver.App.java

public static void main(String[] args) throws Exception {
    //-p --port 9090
    //-r --webcontextroot  webapps
    //-l --logpath logpath
    //-w --war webapp war file name

    CommandLineParser parser = new GnuParser();
    Options options = new Options();
    options.addOption("j", "jettyHome", true,
            "Jetty home, if not set, check system property jetty.home, then default to current Dir");
    options.addOption("p", "port", true, "http server port, default to 9090.");
    options.addOption("c", "webcontextroot", true, "web app url root context, defaul to /");
    options.addOption("l", "logpath", true, "log path, default to current directory.");
    options.addOption("w", "warfile", true, "war file name, default to myperf.war.");
    options.addOption("k", "workdir", true, "work directory for jetty, default to current dir.");

    System.out.println(new Date()
            + " Usage: java -classpath ... com.yahoo.dba.tools.myperfserver.App -j jettyhome -p port -c webcontextroot -k workingDir -l logpath -w war_file");

    App myServer = new App();

    try {/*from w  w  w  .  j  av  a2s .c  o  m*/
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        // validate that block-size has been set
        if (line.hasOption("p")) {
            try {
                myServer.setPort(Short.parseShort(line.getOptionValue("p")));
            } catch (Exception ex) {
            }
        }
        if (line.hasOption("c")) {
            String val = line.getOptionValue("c");
            if (val != null && !val.isEmpty())
                myServer.setContextPath(val);
        }
        if (line.hasOption("l")) {
            String val = line.getOptionValue("l");
            if (val != null && !val.isEmpty())
                myServer.setLogPath(val);
        }
        if (line.hasOption("w")) {
            String val = line.getOptionValue("w");
            if (val != null && !val.isEmpty())
                myServer.setWarFile(val);
        }
        if (line.hasOption("k")) {
            String val = line.getOptionValue("k");
            myServer.setWorkDir(val);
        }
        if (line.hasOption("j")) {
            String val = line.getOptionValue("j");
            if (val != null && !val.isEmpty())
                myServer.setJettyHome(val);
        }
    } catch (ParseException exp) {
        System.out.println("Unexpected exception:" + exp.getMessage());
    }

    System.setProperty("logPath", myServer.getLogPath());

    PID_FILE = myServer.getWarFile().substring(0, myServer.getWarFile().indexOf('.')) + ".pid";
    int historyPid = getHistoryPid();
    if (historyPid >= 0) {
        System.out.println(new Date() + " *************************** WARNING *********************");
        System.out
                .println(PID_FILE + " exists. Possibly another instance is still running. PID = " + historyPid);
        System.out.println(new Date() + " *************************** WARNING *********************");
    }
    if (myServer.startServer()) {
        pid = getPid();
        writePid();
        myServer.waitForInterrupt();
        removePid();
    } else
        System.out.println("Server not started.");
}

From source file:copi.ScalaEntryPoint.java

public static void main(String[] args) {
    /*/*from   w  w w  . j a  v a2 s . c o m*/
       * Set lwjgl library path so that LWJGL finds the natives depending on
       * the OS.
       */
    File libDir = new File(path);

    if (!libDir.exists()) {
        // create native lib folder 
        libDir.mkdir();

        // retrieve os type
        String osName = System.getProperty("os.name");

        // try to determine if the system is 64 bit  
        boolean is64bit = false;
        if (System.getProperty("os.name").contains("Windows")) {
            is64bit = (System.getenv("ProgramFiles(x86)") != null);
        } else {
            is64bit = (System.getProperty("os.arch").indexOf("64") != -1);
        }

        // construct name of native lib file 
        String natLibLWJGL = "";
        if (osName.startsWith("Windows")) {
            natLibLWJGL += "lwjgl";
            if (is64bit)
                natLibLWJGL += "64";
            natLibLWJGL += ".dll";
        } else if (osName.startsWith("Linux")) {
            natLibLWJGL += "liblwjgl";
            if (is64bit)
                natLibLWJGL += "64";
            natLibLWJGL += ".so";
        } else if (osName.startsWith("Mac OS X")) {
            natLibLWJGL += "liblwjgl";
            natLibLWJGL += ".jnilib";
        } else {
            System.out.println("Unsupported OS: " + osName + ". Exiting.");
            System.exit(-1);
        }

        // try to establish an input stream on the native lib inside the jar
        InputStream fis = ScalaEntryPoint.class.getResourceAsStream("/" + natLibLWJGL);
        if (fis == null) {
            System.out.println("Native library file " + natLibLWJGL + " was not found inside JAR.");
            System.exit(-1);
        }

        // establish an output stream on the target file 
        File fOut = new File(path + "/" + natLibLWJGL);
        try (FileOutputStream fos = new FileOutputStream(fOut)) {
            // create file at destination if not already existing
            if (!fOut.exists())
                fOut.createNewFile();

            // making buffer for copy operation 
            byte[] buffer = new byte[1024];
            int readBytes;

            // Open output stream and copy data between source file in JAR and the temporary file
            try {
                while ((readBytes = fis.read(buffer)) != -1) {
                    fos.write(buffer, 0, readBytes);
                }
            } finally {
                fos.close();
                fis.close();
            }
        } catch (IOException e) {
            System.out.println(e.getMessage());
            System.exit(-1);
        }

        // register shutdown hook
        JVMShutdownHook jvmShutdownHook = new JVMShutdownHook();
        Runtime.getRuntime().addShutdownHook(jvmShutdownHook);

    }

    // set lwjgl native library path
    System.setProperty("org.lwjgl.librarypath", libDir.getAbsolutePath());

    // start COPI
    System.out.println("Starting COPI ...");
    (new SICApplicationLogic()).render();
}

From source file:jeplus.Main.java

/**
 * @param args the command line arguments
 *///w w w.  j  a v a  2 s  . co  m
public static void main(String[] args) {
    //        if (REDIRECT_ERR) {
    //            try {
    //                // Redirect err
    //                System.setErr(new PrintStream(new FileOutputStream("jeplus.err")));
    //            } catch (FileNotFoundException ex) {
    //                //Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    //                ex.printStackTrace();
    //            }
    //        }

    try {
        // Set cross-platform Java L&F (also called "Metal")
        //            UIManager.setLookAndFeel(
        //                UIManager.getCrossPlatformLookAndFeelClassName());
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        //                if ("Nimbus".equals(info.getName())) {
        //                    UIManager.setLookAndFeel(info.getClassName());
        //                    break;
        //                }
        //            }
    } catch (UnsupportedLookAndFeelException e) {
        System.err.println("Unsupported Look-And-Feel Option. Reverting to the default UI.");
    } catch (ClassNotFoundException e) {
        System.err.println("Specified Look-And-Feel class cannot be found. Reverting to the default UI.");
    } catch (InstantiationException e) {
        System.err.println("Fialed to instantiate the specified Look-And-Feel. Reverting to the default UI.");
    } catch (IllegalAccessException e) {
        System.err.println("Cannot access the specified Look-And-Feel. Reverting to the default UI.");
    }

    // Set locale to UK
    Locale.setDefault(Locale.UK);
    // Set line end to DOS style
    System.setProperty("line.separator", "\r\n");
    // System.setProperty("file.separator", "/");  // seemed to have no effect

    // create the parser
    CommandLineParser parser = new GnuParser();
    Options options = new Main().getCommandLineOptions(null);
    CommandLine commandline = null;
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(80);
    try {
        // parse the command line arguments
        commandline = parser.parse(options, args);
        if (commandline.hasOption("help")) {
            // automatically generate the help statement
            formatter.printHelp("java -Xmx1000m -jar jEPlus.jar [OPTIONS]", options);
            System.exit(-1);
        }
        // Set log4j configuration
        if (commandline.hasOption("log")) {
            PropertyConfigurator.configure(commandline.getOptionValue("log"));
        } else {
            PropertyConfigurator.configure("log4j.cfg");
        }
    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
        // automatically generate the help statement
        formatter.printHelp("java -Xmx1000m -jar jEPlus.jar [OPTIONS]", options);
        System.exit(-1);
    }

    // Call main fuction with commandline
    new Main().mainFunction(commandline);
}

From source file:com.zf.util.Post_NetNew.java

public static void main(String[] args) {
    //      String ip = "50.115.163.247";
    //      int port = 80;
    //      System.setProperty("http.proxyHost", "localhost");
    //      System.setProperty("http.proxyPort", "1080");
    //      System.setProperty("http.proxyHost", "207.244.64.132");
    //      System.setProperty("http.proxyPort", "8080");
    System.setProperty("proxyHost", "207.244.64.132");
    System.setProperty("proxyPort", "8080");
    //      System.setProperty("http.proxyHost", "207.244.64.132");
    //      System.setProperty("http.proxyPort", "8080");
    //      System.setProperty("socksProxyHost", "103.30.246.43");
    //      System.setProperty("socksProxyPort", "10800");
    //      System.setProperty("socksProxyHost", "localhost");
    //      System.setProperty("socksProxyPort", "1080");
    //      System.setProperty("socksProxyHost", "207.244.64.132");
    //      System.setProperty("socksProxyPort", "8080");

    Map<String, String> map = new HashMap<String, String>();
    //      map.put("url", "http://www.ip.cn");
    //      map.put("url", "https://www.google.com/");
    map.put("url",
            "http://tracking.crobo.com/aff_c?offer_id=21553&aff_id=1478&aff_sub2=P6P49R4873200591858716615&aff_sub=3181");
    //      map.put("url", "http://www.baidu.com");
    try {//from  w w  w  . ja v a 2  s  .c o m
        //         String result = Post_NetNew.pn(map, ip, port);
        String result = Post_NetNew.pn(map);
        System.out.println(result);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:bigtweet.BTSim.java

public static void main(String[] args) {
    System.setProperty("java.util.logging.config.file", "./configuration/logging.properties");
    doLoop(BTSim.class, args);
    System.exit(0);//from w w w  . j a  v a2  s .  com
}

From source file:UnitTest4.java

public static void main(String args[]) {
    System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
    System.setProperty("org.slf4j.simpleLogger.showThreadName", "true");
    System.setProperty("org.slf4j.simpleLogger.levelInBrackets", "true");
    System.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "yyyy-MM-dd HH:mm:ss:SSS Z");
    System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
    System.setProperty("org.slf4j.simpleLogger.showLogName", "true");

    final Logger log = LoggerFactory.getLogger(UnitTest4.class);
    UnitTest4.log = log;/*from   w ww.j  a v  a  2 s .com*/
    System.out.println("hdfjkv \'dfdgdf\'dgdf");
    try {

        throw new Exception();
    } catch (Throwable e) {

        log.debug(e.toString());
        //log.debug(" Cause : " + e.getCause().toString());
        StackTraceElement stacka[] = e.getStackTrace();
        for (StackTraceElement stack : stacka) {
            log.debug(" StackTrace : " + stack.toString());
        }
    }

    String a[] = new String[10];
    a[0] = "hwedf";
    a[6] = "wdeeg";
    log.debug("a.toString() : {}", a.toString());

    /*
    List<Integer> list = new ArrayList<Integer>();
    for (Integer i : list) {
            
    System.out.println(i);
    }
    System.out.println("ok");
    try {
       //Test2.execute();
    } catch (Exception e) { e.printStackTrace(); }
    */
}

From source file:io.uploader.drive.DriveUploader.java

public static void main(String[] args) {

    if (isMacOsX()) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name",
                Configuration.INSTANCE.getAppName());
        try {/*from   ww w.  j  a  va  2s  .  c om*/
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException e) {
            logger.error("Error occurred while initializing the UI", e);
        }
    }

    Platform.setImplicitExit(false);

    // load the settings
    String settingsFile = "driveuploader-settings.xml";
    if (!new java.io.File(settingsFile).exists())
        settingsFile = null;
    try {
        Configuration.INSTANCE.load(settingsFile);
    } catch (ConfigurationException e) {
        logger.error("Error occurred while initializing the configuration", e);
    }

    try {
        // initialize the transport
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();

        // initialize the data store factory
        dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);

    } catch (IOException e) {
        logger.error("Error occurred while initializing the drive", e);
        Platform.exit();
    } catch (Throwable t) {
        logger.error("Error occurred while initializing the drive", t);
        Platform.exit();
    }

    launch(args);
}

From source file:Test5.java

public static void main(String args[])
        throws IOException, ParseException, DScabiClientException, DScabiException, java.text.ParseException {
    System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
    System.setProperty("org.slf4j.simpleLogger.showThreadName", "true");
    System.setProperty("org.slf4j.simpleLogger.levelInBrackets", "true");
    System.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "yyyy-MM-dd HH:mm:ss:SSS Z");
    System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
    System.setProperty("org.slf4j.simpleLogger.showLogName", "true");
    //System.setProperty("org.slf4j.simplelogger.defaultlog", "debug");
    //System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
    final Logger log = LoggerFactory.getLogger(Test5.class);
    System.out.println("Test5");
    DMeta meta = new DMeta("localhost", "5000");

    Dson dson = new Dson();
    dson.add("Namespace", "MyCompany-Tables");
    dson.add("Type", DNamespace.APPTABLE);
    dson.add("Host", "localhost");
    dson.add("Port", "27017");
    dson.add("UserID", "myuser");
    dson.add("Pwd", "hello");
    dson.add("SystemSpecificName", "MyCompanyDB");
    dson.add("SystemType", "MongoDB");

    try {/*w  w  w .  j a  v a2  s.  com*/
        if (false == meta.namespaceExists("MyCompany-Tables")) {
            System.out.println("Register new namespace");
            meta.namespaceRegister(dson);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    Dao dao = new Dao(meta);

    // The below examples demonstrate CRUD operations

    // Create Table
    try {
        if (false == dao.tableExists("scabi:MyCompany-Tables:Table1")) {
            System.out.println("Create Table");
            DTable t = dao.createTable("scabi:MyCompany-Tables:Table1");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    // Get existing Table
    DTable table = dao.getTable("scabi:MyCompany-Tables:Table1");

    // Insert data
    if (0 == table.count()) {
        try {
            System.out.println("Insert data");
            DDocument d = new DDocument();
            d.append("EmployeeName", "Karthik").append("EmployeeNumber", "3000").append("Age", 40);
            table.insert(d);

            d.clear();
            d.append("EmployeeName", "Jayaprakash").append("EmployeeNumber", "3001").append("Age", 35);
            table.insert(d);

            d.clear();
            d.append("EmployeeName", "Arun").append("EmployeeNumber", "3002").append("Age", 30);
            table.insert(d);

            d.clear();
            d.append("EmployeeName", "Balaji").append("EmployeeNumber", "3003").append("Age", 35);
            table.insert(d);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // Update records
    System.out.println("Update records");
    DDocument d2 = new DDocument();
    d2.put("Age", 45);
    DDocument updateObj = new DDocument();
    updateObj.put("$set", d2);
    table.update(eq("EmployeeName", "Balaji"), updateObj);

    // Query data
    // Directly embed Mongo queries using filters : and, or, lt, gt, etc.
    System.out.println("Query data");
    DResultSet result = table.find(or(eq("EmployeeNumber", "3003"), lt("Age", 40)));
    while (result.hasNext()) {
        DDocument d3 = result.next();
        System.out.println("Employee Name : " + d3.getString("EmployeeName"));
        System.out.println("Employee Number : " + d3.getString("EmployeeNumber"));
        System.out.println("Age : " + d3.getInteger("Age").intValue());
    }

    dao.close();

    meta.close();

}