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

public static void main(String[] args) {

    Long v = new Long(1234567890);

    System.setProperty("Java2s.com", "12345");
    String str = "Java2s.com";
    System.out.println(Long.getLong(str, v));

    System.out.println(Long.getLong("java", v));
}

From source file:MainClass.java

public static void main(String[] a) {
    String oldValue = System.clearProperty("java.class.path");
    System.setProperty("user.dir", "C:/MyProg");
    System.out.println(System.getProperty("user.dir"));
}

From source file:Main.java

public static void main(String[] args) {

    String s = System.clearProperty("java.class.path");

    System.setProperty("user.dir", "C:/java2s.com");

    System.out.println(System.getProperty("user.dir"));
}

From source file:Main.java

public static void main(String[] args) {
    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new Main();

    System.setSecurityManager(sm);

    sm.checkRead("test.txt");

    System.out.println("Allowed!");
}

From source file:Main.java

public static void main(String[] args) {
    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new Main();

    System.setSecurityManager(sm);

    sm.checkPermission(new FilePermission("test.txt", "read,write"));

    System.out.println("Allowed!");
}

From source file:Main.java

public static void main(String[] args) {
    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new Main();

    System.setSecurityManager(sm);

    FileDescriptor fd = new FileDescriptor();
    sm.checkRead(fd);// ww w .j  av  a  2 s. com

    System.out.println("Allowed!");
}

From source file:Main.java

public static void main(String[] args) {

    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new Main();

    System.setSecurityManager(sm);

    sm.checkWrite("test.txt");

    System.out.println("Allowed!");
}

From source file:Main.java

public static void main(String[] args) {

    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new Main();

    System.setSecurityManager(sm);

    FileDescriptor fd = new FileDescriptor();
    sm.checkWrite(fd);/*from  www  .j  av  a 2 s . c  o  m*/

    System.out.println("Allowed!");
}

From source file:Main.java

public static void main(String[] args) {
    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new SecurityManager();

    System.setSecurityManager(sm);

    // perform the check
    sm.checkCreateClassLoader();/*w  w  w  . ja  v  a 2 s  . co  m*/
    System.out.println("Allowed!");
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.parsers.SAXParser");
    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser = factory.newSAXParser();

}