Setting the Security Manager
In an RMI application, if no security manager is set, stubs and classes can only be loaded from the local CLASSPATH.
To enable dynamic loading, issue the command:
System.setSecurityManager(new RMISecurityManager()) ;
at the start of the program.
You should do this in any application that may have to download code—in the simple examples considered so far this means RMI clients that need to download stubs.
This isn’t the end of the story. You also have to define a new property: the java.security.policy property.
- In simple cases this property is needed for clients, whereas java.rmi.server.codebase is needed for servers.