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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI Concepts" Watch "RMI Concepts" New topic
Author

RMI Concepts

Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 268
Hi All,

I have the following RMI files :

(I) Interface




(II) RemoteServer




(III) Client




I was able to successfully run these programs in Eclipse in a standalone env.

Now I have the following questions to clear my concepts :

1. There was no need of policy file. Why?

2. There was no need to run the following set of commands from command line. Why ?

Microsoft Windows:

java -cp c:\home\ann\src;c:\home\ann\public_html\classes\compute.jar
-Djava.rmi.server.codebase=file:/c:/home/ann/public_html/classes/compute.jar
-Djava.rmi.server.hostname=zaphod.east.sun.com
-Djava.security.policy=server.policy
engine.ComputeEngine

3. There was no need to mention the codebase. Why ?

4. In the following line
MyRemote service = (MyRemote)Naming.lookup("rmi://127.0.0.1:1099/RemoteHello");

even If I change the IP address to let say :

i) rmi://127.33.4.5
ii) rmi://127.22.44.56

OR anything after rmi://127. . . .then it works Why ?

If I change the first number rmi://200. . . . then it dosen't work.


*5. Why Naming.rebind() dosen't work ?
[size=12]


Futhermore, I would like to enhance this application to have the server running in one machine and then let the various clients (which would be on different computers) and let the clients connect to the server machine. I would like to run my RMI program in a networked environment.

I would like to make a chat application using RMI.

Please do guide me.


Thanks
Siddharth
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2615
    
    9

Hmm interesting questions. Yet I don't know all of them or simply the "why" but note the following about RMI:

* Stubs and skeletons are NOT mandatory if you are using JDK5 or higher
* If you don't have classpath set for those jar files or whatever files, I believe it "dynamically" find it for you. How I don't know. And there is another concept called "dynamic class loading" which is not related.
* security manager is needed if you want http tunnelling or dynamic class loading or creating new RMI instances everytime (called Activatable inteface)
* Naming.rebind() doesn't work ... I believe cos you need a JNDI for it to lookup which usually requires a app server
* and this is the really fun fact or note: if the server starts using IP 1 then client code MUST bind with that server using same IP1 (can't be the hostname for that computer). A simple test you can try start with 127.0.0.1 then connect with "localhost" and vice versa.

I may be wrong on some of these. Based on what you have, it looks you have read the RMI tutorial. Maybe you should read the RMI book by Rosso to get in depth understanding. I read that book earlier this year got what I needed .... and now can't recall

Hope this helps a bit.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Siddharth Bhargava wrote:
[color=blue][size=12]1. There was no need of policy file. Why?


Because you did not enable the Security manager.

Siddharth Bhargava wrote:There was no need to run the following set of commands from command line. Why ?

Microsoft Windows:

java -cp c:\home\ann\src;c:\home\ann\public_html\classes\compute.jar
-Djava.rmi.server.codebase=file:/c:/home/ann/public_html/classes/compute.jar
-Djava.rmi.server.hostname=zaphod.east.sun.com
-Djava.security.policy=server.policy
engine.ComputeEngine


These are not mandatory properties. Codebase is used for remote class downloading. Hostname is required if you specifically want to assign a specific IP address to be used by the stubs.

Siddharth Bhargava wrote:
3. There was no need to mention the codebase. Why ?


It is not mandatory.

Siddharth Bhargava wrote:
4. In the following line
MyRemote service = (MyRemote)Naming.lookup("rmi://127.0.0.1:1099/RemoteHello");

even If I change the IP address to let say :

i) rmi://127.33.4.5
ii) rmi://127.22.44.56

OR anything after rmi://127. . . .then it works Why ?

If I change the first number rmi://200. . . . then it dosen't work.


IP addresses starting with 127. are usually mapped to one of the local interfaces. Your m/c would have these interfaces configured. Whatever you specify in the URL, must be a valid IP.


apigee, a better way to API!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI Concepts