I just "created" a Client-Server Java RMI on the same java virtual machine(it's a trivial thing an RMI on the same machine). I want to use a Client-Server RMI remotely. I'll use two machines: the first, called A, will be the Server; the second, called B, will be the client. So I want to know which are the differents beewten remotely and locally RMI Client-Server. For example, on machine A:
- I write the code for the RemoteInterface extends Remote;
-
I write the code for the class of real remote object:
public class RemoteObj extends UnicastRemoteObject implements RemoteInterface -
I write the code for the server side which I bind the remoteObj using the IP of the machine A on the neetwork
public class Server { ............ RemoteObj obj = new RemoteObj(); String globalName = "rmi//IP_machine_A/hello"; Naming.rebind(globalName, obj); -
I use the rmic RemoteObj command to auto generate the stub
- I use the start rmiregistry command to start RMI registry server
- Finally I must start the server
On the machine B, instead:
-
I write the code for Client, which I lookup the rmi registry with the global name:
public class Client { ....... String globalName = "rmi//IP_machine_A/hello"; RemoteInterface remoteObj = (RemoteInterface)Naming.lookup(globalName); -
I must start the client
Are these statementes correct? Thanks guy
Aucun commentaire:
Enregistrer un commentaire