• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

RMI Concepts

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic