java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:2222" "listen,resolve")

System.setSecurityManager(new SecurityManager());
final int port = 2222;
try {
Registry registry = LocateRegistry.getRegistry(PORT);
StubRealize stub = new StubRealize();
Stub serverStub …