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[] argv) throws Exception {
    String previousValue = System.setProperty("application.property", "newValue");
}

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.checkPrintJobAccess();/*www. ja va  2  s.co 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 Main();

    System.setSecurityManager(sm);

    sm.checkSecurityAccess("read");

    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.checkPropertiesAccess();/*from   ww  w  . j ava2  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 Main();

    System.setSecurityManager(sm);

    sm.checkPropertyAccess("java.runtime.name");

    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);

    boolean checked = sm.checkTopLevelWindow("Window");
    System.out.println(checked);/*from w w w  .  j  a  v a 2s  .  c o m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    System.setProperty("java.version", "data");

    try {/*w w w.  j av  a2  s . c o m*/
        SecurityManager sm = new SecurityManager();
        System.setSecurityManager(sm);
    } catch (SecurityException se) {
        se.printStackTrace();
    }

    // no longer possible; an AccessControlException is thrown
    System.setProperty("java.version", "malicious data");
}

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.checkSystemClipboardAccess();/*from   www  .j  a v  a  2s. co 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 Main();

    System.setSecurityManager(sm);

    sm.checkSetFactory();/*from   ww  w  .  ja v  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 Main();

    System.setSecurityManager(sm);

    Class[] con = sm.getClassContext();

    for (int i = 0; i < con.length; i++) {
        System.out.println(con[i]);
    }//from   w  w  w . java 2 s . com
}