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

[2038 byte] By [NoRationalSolutiona] at [2007-11-27 10:40:12]
# 1

You need to start the RMI Registry: rmiregistry.exe or rmiregistry depending on your platform, before you start your server. Get rid of the security manager for the moment.

ejpa at 2007-7-28 19:05:29 > top of Java-index,Core,Core APIs...
# 2

Thanks A lot!

That seems to have been the issue, well apparently one of them. Now i suddenly have 12 errors all saying that they cannot find the Interface. This is strange because i have checked the spelling and can't seem to find out why this is so. I will look further into it.

NoRationalSolutiona at 2007-7-28 19:05:29 > top of Java-index,Core,Core APIs...
# 3

You Also said something about leaving it "For the moment" if this server were to be used across machines would I have to reinsert the code?

NoRationalSolutiona at 2007-7-28 19:05:29 > top of Java-index,Core,Core APIs...
# 4

Only if you are going to use the codebase feature, and then you would normally only do that at the client, not the server.

The .class files for the remote interface any application classes it refers to, and so on to closure, have to be available on the classpath of both the Registry and the client.

ejpa at 2007-7-28 19:05:29 > top of Java-index,Core,Core APIs...