File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI" Watch "RMI" New topic


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?
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

Joined: Feb 05, 2001
Posts: 17276

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

Darn, you know my tricks.

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
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.

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: 11778

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 your browser will normally automatically assume that you mean to use HTTP, and automagically prefix your URL so that it appears as 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
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, or you can say 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:
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 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
    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
    I agree. Here's the link:
    subject: RMI
    jQuery in Action, 3rd edition