RMI generates a client-side file with a main() method that looks like the following example:
public static void main (String[] args) {
System.setSecurityManager (new RMISecurityManager());
}
To complete your client class, you must add a lookup() call that returns a reference to the correct RMI server. You can use the reference to invoke server-side methods.
To add a lookup() call:
You need to know which RMI registry it is registered with. In a large development effort, the server might be under control of a system administrator or another developer. If you are doing all the development work, you can start the server yourself.
The main() method should resemble the following example:
To add server method invocations:
The object returned by the lookup is a proxy for the RMI server. You can invoke methods on it. Use code like this:
Your completed main method should look like this:
See also | |
---|---|
Generating a Client-side File
Compiling and Running a Client-side File |