System.setSecurityManager(): This method is available in java.lang.System class of Java.
Syntax:
void java.lang.System.setSecurityManager(SecurityManager sm)
This method takes one argument of type SecurityManager as its parameter. This method sets the system-wide security manager.
Parameters: One parameter is required for this method.
sm: the security manager or null.
Throws:
1. SecurityException - if the security manager has already been set and its checkPermission method doesn't allow it to be replaced.
2. UnsupportedOperationException - if sm is non-null and a security manager is not allowed to be set dynamically
Approach
Java
public class SystemsetSecurityManager {public static void main(String[] args) {SecurityManager sm = null;System.setSecurityManager(sm);System.out.println("Successfully sets Security Manager");}}
Output:
Successfully sets Security Manager
No comments:
Post a Comment