In simple terms, stubs are the implementation of proxy pattern,
Stubs are proxies of the server objects resided on client in order to make the complexity of remove communication transparent from the client application. As your client app is not capable of downloading the actual code, stubs reside on the client to marshal the information and tunnel them over the wire to the remove server where the skeleton objects are loaded. There, the data will be unmarshalled and passed to the server objects bounded on the server registry.
Note that in RMI you are able to keep the stub on the server and download them on demand, but as far as I can remember, you don't have this functionality. (May be in Java Corba you can)
If this is RMI, then the protocol that stub is running on is JRMP and if this is Corba, it uses IIOP, GIOP
Although RMI/IIOP is also supported, but now if you are looking for documents for more detailed information, you should tell us which technology you are using.
From the coding point of view, once you got your interface agreed on, pass it to the compiler (whatever tech you're using) and that will give you the stub. You can compile it then with your client code and all done.
It was brief, but once you knew the technology, you can easily access the documents.