This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI" Watch "RMI" New topic
Author

RMI

Denis Spirin
Ranch Hand

Joined: Mar 22, 2004
Posts: 72
It may be silly question, but whats the difference between "rmi://etc" and "//etc" ?
It seems that both work on Mac and Windows, but why in Sun documentation it is said that:
Each method of the Naming class takes as one of its arguments a name that is a java.lang.String in URL format (without the scheme component)

In documentation to other RMI methods this is constantly repeated.
In RMI tutorial:
Also, you don't need to specify a protocol in the URL.

So I dont need or I should not?
Thanks
PS. Pls dont tell me that difference between them is 4 letters


Regards<br /> <br />Ph.D.<br />SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD 2
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

PS. Pls dont tell me that difference between them is 4 letters

Darn, you know my tricks.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Here's my guess:
You don't need to specify the protocol (which is what "rmi:" is in the URL) because you're registering, or looking up, a remote object. The protocol used to retrieve the object has no bearing on it's name.
As I said, it's my guess. If anybody else wants to supply the correct answer, please do so. I'm curious.
Burk


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Denis Spirin
Ranch Hand

Joined: Mar 22, 2004
Posts: 72
[to Mark]
"I was gratified to be able to answer promptly. I said I don't know." Mark Twain.
"The important thing is not to stop questioning." Albert Einstein.

[ April 16, 2004: Message edited by: Denis Spirin ]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11490
    
  95

Hi Denis,
You do not need to specify the protocol in the URL, however it doesn't hurt to do so (especially if you are persisting the URL in some file where the average reader may not understand what it is for).
Basically the RMI methods expect to use RMI to connect. (Funny about that. ) So they don't need the "rmi:" protocol prefix.
The same as web browsers usually expect to be connecting to a web server, so they usually do not need you to enter the http: protocol prefix. If you type in www.javaranch.com your browser will normally automatically assume that you mean to use HTTP, and automagically prefix your URL so that it appears as http://www.javaranch.com. Specifying the protocol is only necessary if you want to use some other protocol - for example, if you want to connect to an FTP server via your web browser, in which case you would prefix the URL with "ftp:" (for example ftp://homelinux.yi.org/).
Most web browsers (in fact all that I can remember) also do not need the port you are connecting to - they automatically assume that you are connecting to port 80. So you can be explicit and say http://www.javaranch.com:80/, or you can say http://www.javaranch.com and your browser will still get to exactly the same place. Specifying the port is only necessary if you want to go to a non standard port (For example, the ISSN web page is on port 8080, not port 80, so if you want to go to their page you have to enter the port number in the URL: http://www.issn.org:8080/pub/).
The same applies to RMI: by default, all the RMI methods assume that you are going to use RMI, that you are connecting to the local host, and that you are using port 1099. So all the following are equivalent:
  • rmi://localhost:1099/test
  • //localhost:1099/test
  • rmi://localhost/test
  • /test


  • (And many more, I got bored after the first four )
    But, as mentioned earlier, you might want to give a fully qualified URL if there is any possibility that someone may look at your properties file directly - in this case having the fully qualified URL would make more sense to the reader.
    Regards, Andrew
    [Sorry, UBB automatically prefixes http: to URLs with no protocol, so my example of www.javaranch.com does not really work the way I wanted it to]
    [ April 15, 2004: Message edited by: Andrew Monkhouse ]

    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Denis Spirin
    Ranch Hand

    Joined: Mar 22, 2004
    Posts: 72
    Andrew,
    thank you for the answer! Ive never seen explanation about "rmi:" anywhere, Sun only mentions default port and host, bu not protocol. Anyway, I compared documentation for 1.3
    and 1.4 versions. In 1.4 "without the scheme component" appears, but it is absent in 1.3.
    Thats one of the reasons why on documntation we can earn 70 points
    Regards
     
    wood burning stoves
     
    subject: RMI