Java RMI : What is the role of the stub-skeleton that are generated by the rmic compiler

user2435860 picture user2435860 · Jun 2, 2013 · Viewed 18.5k times · Source

I am currently learning Java RMI (Remote Method Invocation), and I followed the tutorial provided by Oracle on it´s website. I have a particular question however:

What is the use of the stub-skeleton generated by rmic? Do I really need it?

Answer

Thomas picture Thomas · Jun 2, 2013

The Stub/Skeleton hides the communication details away from the developer. The Stub is the class that implements the remote interface. It serves as a client-side placeholder for the remote object. The stub communicates with the server-side skeleton. The skeleton is the stub's counterpart on server-side. Both communicate via the network. The skeleton actually knows the real remote objects delegates the stub's request to it and returns the response to the stub. You require both as they are the essential building blocks for RMI.