Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My RMI client consists of a Java command-line app

 
Naidu Sanapala
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

My RMI client consists of a Java command-line app that uses Naming.lookup to obtain a reference to the remote interface. As one needs to typecast the return object to the remote interface, the client code depends on the remote interface for successful compilation and execution.

Also, I have a data class that is used by both the RMI server components and RMI client components. This is the return type for the remote method invoked by the client.

What is the correct approach out of the options given below?

a) Include the remote interface and the data class in the build classpath. This is inevitable during development and is the only way to compile the client app and remote implementation code.

However, at the time of execution, you may just mention the codebase so that the remote interface and/or data class bytecode gets downloaded. This is applicable to both the client app and the remote implementation.

b) Include the remote interface and the data class in both the build and run classpath. This is inevitable and is the only way to compile and execute the client app and remote implementation.

I would greatly appreciate your answers to my query.

If there is any other approach apart from the ones that I have mentioned, please let me know.

Thanks,
Naidu Sanapala
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either of these approaches can be used, however, most are going to go with the (a) approach. Using dynamic RMI classloading makes your code more flexible to change, and if you need to make changes or fixes to some classes, you won't need to re-deploy code to all your clients - they get this code dynamically from the server, so they will always get the newest code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic