Say I take some class file: how can I know if it is a stub or a plain class file? Do not tell me by file name. I need a technical answer that is made on the basis of the content of the binary file.

Luigi Viggiano

A stub is just a dummy implementation of a remote object interface delegating the real job using network.
To understand if a class is a businness object or just a stub you have to check its source code and understand its behaviour. If it does businness jobs directly it's a plain class, otherwise, if it just acts like an intermediate to the network layer it's a stub.

For RMI, at runtime you can check if the class is instance of java.rmi.server.RemoteStub, if yes it's a stub, otherwise is a plain class.