RMI Remote Method Call Interpretation Tutorial 1, RMI Overview RMI is a distributed object package, which simplifies communication between Java applications on multiple computers. You must use the class java.rmi.Rmi.Remote used by RMI above JDK1.1 All objects that can be remotely called must implement the interface java.rmi.server.UnicastRemoteObject All objects that can be called must expand what is RMI? Remote method call is a mechanism between a computer between a computer to call each other, starting a mechanism for the other party process, using this mechanism, an object on a computer, using the program syntax used by the method on another computer The rules and the grammar rules that are called between the objects between the local machine. Advantages This mechanism is designed to distribute system design, and programming has brought great convenience. Just follow the RMI rules design, you can do not have to ask the network details below RMI, such as TCP and Socket, etc. The communication between any two computers is completely responsible by RMI. Calling objects on a remote computer is just as convenient to local objects. 1. Object-oriented: RMI can pass the complete object as a parameter and return value, not just a predefined data type. That is, complex types such as Java Haxi table can be passed as a parameter. 2. Movable properties: RMI can move the property from the client to the server, or move from the server to the client. 3, design: Object transfer enables you to make full use of power-oriented technology, such as two-layer and three-layer structural systems in distributed computing. If the user can pass attribute, you can use object-oriented design in your own solution. All object-oriented design methods do not rely on different properties to function, if the full object cannot be passed - including implementation and type - will lose the advantages provided in design. 4, security: RMI uses Java built-in security mechanism to ensure the security of user systems when downloading executing programs. RMI uses a safety management procedure designed to protect the system from malicious applets. 5. Easy to write and use RMI to make the Java remote service program and access to the Java clients accessing these servers easily, simple. The remote interface is actually a Java interface. In order to implement the function of RMI, you must create a remote object any object that can be called to be called must implement a remote interface. However, the remote interface itself does not contain any way. Thus you need to create a new interface to extend the remote interface. The new interface will contain all methods that can be called remotely. Remote objects must implement this new interface. Since the new interface extends the remote interface, the new interface is realized, which satisfies the requirements of the remote object on the implementation of the remote interface, and each object implemented is referenced as a remote object reference. Create a remote method call 5 steps: 1. Define a remote interface interface, each method in the interface must declare it will generate a RemoteException exception. 2. Define a class that implements the interface. 3. Use the RMIC program to generate the residual root and framework required for remote implementation. 4. Create a client program and the server for RMI calls. 5. Start Registry and run your remote server and client. The first step is that the extended remote interface creates an RMI program first to do to create an interface that extends the remote interface. In this interface, you can add any way you want to be called on a remote machine. Interface example import java.rmi.Remote; import.java.rmi.RemoteException; public interface RemoteInterface extends java.rmi.Remote {public String start (String msg) throws RemoteException;} defines a method returns a string in a local interface The interface must be public, otherwise the client will errors when loading a remote object that implements the interface. It must inherit from java.rmi.Remote, each method in the interface must throw a remote exception java.rmi.RemoteException.