0

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)?

user207421
  • 305,947
  • 44
  • 307
  • 483

1 Answers1

1

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.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • @EJB Thank you, I haven't heard of this before. Good to know. – Thomas Uhrig Oct 14 '15 at 20:41
  • Thanx ,I understood from your answer, the client use reflection to operate the stub class,can you give me an example about this(how to use java reflection to download the stub class)? – MANAR HUSAM Oct 15 '15 at 10:44
  • It seems you understood nothing. The client doesn't need to use reflection to operate the stub class, and the codebase feature does the downloading, not Reflection. I have no idea why you're asking me for an example of something I've already described as impractical. – user207421 Oct 15 '15 at 11:35