Now let's examine the steps involved in writing an RMI standalone application. As usual, we code the "main" method as the entry point, and in it, we perform the RMI initialization steps. We first set the security manager so that the RMI runtime can download class files, then obtain a reference to the remote object by using the RMI naming registry. Then we can call remote methods.
While this code shows calling remote methods only in the "main" method, once your application has retrieved the object reference, the application can call methods during other methods, too. In addition, note that there's no clean-up required; the Java and RMI infrastructure work together to make sure that garbage collection work, even on remote objects.
We will now examine these steps in more detail.