Search code examples
javarmidistributed-systemcodebase

Java Remote Method Invocation(RMI): codebase property


How to use the codebase java property to download the(Interface and Stub class)from the sever to the client computer, in java RMI(Remote Method Invocation)?


Solution

  • How to use the codebase java propriety to download the(Interface and Stub class)from the sever to the client computer, in java RMI(Remote Method Invocation)?

    You just define the system property java.rmi.server.codebase at the JVM which exports the remote object. NB not at the client JVM or Registry. The codebase property value is a list of one or more URLs where classes can be downloaded from. Usually it is one HTTP URL pointing to a JAR file contain the classes to be downloaded, which only need to include the stub, if you use one, and any concrete classes which are going to be supplied as actual return types implementing interfaces or abstract or base classes mentioned in the remote interface as return types, or via such classes as dependencies.

    However it usually isn't practical to download the remote interface itself, as it would mean that the client has to use Reflection to operate the stub. Usually the client already has the remote interface and uses it directly.

    Note also that since Java 1.5 you don't need generated stubs.