RMI, you are my Everest !
Hello,
I'm a student and I'm new to networking in java. For the purposes of my project RMI seems to be an ideal solution, whats more I really want to master what looks like a powerful tool.
Below I will post 3 classes and the code which i use to compile the main one. If its not to much trouble could someone please help me out. I know my mistake may be very simple :)
public class Server {
public Server(String serverName){
//
//With the manager I get "access denied", i tried commenting it out and I get "Connection refused to host"
System.setSecurityManager(new RMISecurityManager());
//-
try {
Speaker speaker=new Speaker();
Registry registry = LocateRegistry.getRegistry();
registry.rebind(serverName, speaker);
System.out.println("Server Started!");
} catch (Exception e) {
e.printStackTrace();
}
//--
}
public static void main(String[] args){
new Server("SudokuServer");
}
}
public interface ServerInterface extends Remote {
public void hello(String saySomething) throws RemoteException;
}
public class Speaker extends UnicastRemoteObject implements ServerInterface{
public Speaker()throws RemoteException{
super();
}
public void hello(String in)throws RemoteException{
System.out.println(in);
}
}
As i said above I get the error :"Access Denied" With the security Manager on and "Cannot Host..." with it off.
I am using Eclipse at the moment but i started rather compiling from prompt when i heard that i needed a policy file.
The policy File used:
grant{
permission java.security.AllPermission;
};
and The batch File used:
java -Djava.security.policy=DefultSecurity.policy Server
pause
To clarify I keep the security Manager in and run from the batch file and get a "Connection refused to Host"
Could anyone help me out, please.
Thanks
-Greg

