List of usage examples for java.lang System setProperty
public static String setProperty(String key, String value)
From source file:MainClass.java
public static void main(String[] args) throws Exception { System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); URL url = new URL("https://www.verisign.com/"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String line;/*from w ww . j a va2 s.c o m*/ while ((line = in.readLine()) != null) { System.out.println(line); } in.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { InetAddress add = InetAddress.getLocalHost(); System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); sm.checkMulticast(add);//from w ww . j a va 2s.c o m System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) throws Exception { System.setProperty("oracle.net.tns_admin", "C:/app/product/11.2.0/client_1/NETWORK/ADMIN"); String dbURL = "jdbc:oracle:thin:@ENTRY_FROM_TNSNAMES"; Class.forName("oracle.jdbc.OracleDriver"); Connection conn = DriverManager.getConnection(dbURL, "your_user_name", "your_password"); System.out.println("Connection established"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT dummy FROM dual"); if (rs.next()) { System.out.println(rs.getString(1)); }//from w w w .j a v a2 s . co m stmt.close(); conn.close(); }
From source file:Main.java
public static void main(String[] args) { AccessControlContext acc = AccessController.getContext(); System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new SecurityManager(); System.setSecurityManager(sm); // perform the check sm.checkConnect("www.java2s.com", 8080, acc); System.out.println("Allowed!"); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { System.setProperty("javax.net.ssl.keyStore", "mykeystore"); System.setProperty("javax.net.ssl.keyStorePassword", "wshr.ut"); SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); ServerSocket ss = ssf.createServerSocket(5432); while (true) { Socket s = ss.accept();// w w w . java2 s . co m PrintStream out = new PrintStream(s.getOutputStream()); out.println("Hi"); out.close(); s.close(); } }
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); // perform the check sm.checkListen(8080);// w w w .j a v a 2s.c o m System.out.println("Allowed!"); }
From source file:Main.java
public static void main(String[] args) { AccessControlContext con = AccessController.getContext(); System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); sm.checkRead("test.txt", con); 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); // perform the check sm.checkExit(5);/*from w w w.j av a2 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"); Main sm = new Main(); System.setSecurityManager(sm); // check if accepting access for thread is enabled sm.checkAccess(Thread.currentThread()); 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.checkPackageAccess("java2s.com"); System.out.println("Allowed!"); }