baci se izuzetak sa opisom da je pristup odbijen.
Meni iskreno receno nije jasno ni zasto sluzi linija koda System.setSecurityManager(new RMISecurityManager());
Trazio sam po netu i nasao da se prava pristupa dodeljuju tako sto u *.policy fajlu napsemo
grant{
permission java.security.AllPermission;
};
pa se onda virtuelnoj nasini naglasi da koristi ovo ali nista ne vredi
osto je kod jednostavan prilazem i njega:
public class Client {
public static void main(String[] args){
System.setSecurityManager(new RMISecurityManager());
try {
Server server=(Server) Naming.lookup("rmi://localhost:4099/Server");
int rez=server.getBroj();
System.out.println(rez);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NotBoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public class Server extends UnicastRemoteObject implements ServerI {
public Server()throws RemoteException{}
public int getBroj()throws RemoteException{
return 5;
}
public static void main(String[] argv){
System.setSecurityManager(new RMISecurityManager());
try {
Server server=new Server();
LocateRegistry.createRegistry(4099);
Naming.rebind("rmi://localhost:4099/Server",server);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public interface ServerI extends Remote{
public int getBroj()throws RemoteException;
}
Sta je ovde problem
Kad covjeka napusti Sunce njegovog zavicaja ko ce mu posvijetliti na putu povratka