aspose file tools*
The moose likes Distributed Java and the fly likes Question about RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Question about RMI" Watch "Question about RMI" New topic
Author

Question about RMI

Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

Hello,
I've one question regarding RMI:
while reading about this technology ,some problems arises to me in understanding how does it work especially this line:
For an object to be invoked remotely, it must be defined in a Java interface accessible to both the server and the client
Why we have to define a java interface instead of using a class that directly implements Remote interface???
I'm confused in this ..
I'd be grateful if you can help me


I Hear I Forget, I See I Remember, I Do I Understand.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4367
    
    8

The class that is going to be invoked sits on the server, but the client also needs to know what the methods are. The client doesn't need any information about the implementation of the class, so distributing the class to the client is inappropriate. It just needs to know the interface.

So you define and distribute the interface. Then on the client side, the RMI framework will create a stub class for you that implements that interface. You call the methods on that, and the stub sorts out the communication with the server for you.
Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

Thanks "Matthew Brown" very much for your valuable help.
but I've another questions:
When the client look for a server object in RMI registry and locate it , it return a server stub.
What is the meaning of server stub?
second:
I know that when Developing RMI applications we must Define a server object interface that serves as the contract between the server and its clients, as shown in the following outline:

Why the server object interface must extend the java.rmi.Remote interface???.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about RMI