• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

naming is it OS specific

 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
In RMI while binding the name to RMI registry if we enter the name as
String name = "rmi://" + ip + ":" + port + "/Server";
Does it by any chance tied to windows environment? What I mean is that the seperator "/", is it tied to windows environment ? If the answer is Yes, we need to pick up the OS specific separator in case we aim to make our application run on multiple OS.
Similarly, when we look up this name from registry.
I do something like this.
String svr = "rmi://" + ip + ":" + port + "/Server";
return (RemoteDataIntf) Naming.lookup(svr);
Have I hardcoded the seperator to a particular OS i.e windows ?
Thanks
Ravi
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I think in the case of rmi:// like http:// is the same accross platforms.
I have the /s hardcoded and they work in both Windows and UNIX.
Now if you are trying to get a file, then you can use the os.seperator "Constant" to get the correct slash in those cases.
Mark
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

String name = "rmi://" + ip + ":" + port + "/Server";
Does it by any chance tied to windows environment?

No, it is cross-platform because it is a URL-formatted String, so you are OK. Here is more from Sun's Javadoc for Naming class:
"The Naming class provides methods for storing and obtaining references to remote objects in the remote object registry. The Naming class's methods take, as one of their arguments, a name that is a URL formatted java.lang.String of the form:
//host: port/name
where host is the host (remote or local) where the registry is located, port is the port number on which the registry accepts calls, and where name is a simple string uninterpreted by the registry. Both host and port are optional. If host is omitted, the host defaults to the local host. If port is omitted, then the port defaults to 1099, the "well-known" port that RMI's registry, rmiregistry, uses."
Incidentally, you are using "ip" as a variable name to specify the host, does it mean you expect it to be an IP address? What happens if your user specifies "FatBrain" and the server name, -- will your program still work?
Eugene.
[ February 19, 2003: Message edited by: Eugene Kononov ]
 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eugene
I am not sure how the program would behave if given such a input.
However I tested the application in an intranet environment with the rmi server running on linux and the ip address of the machine being 192.168.0.6 . I binded the server name rmi://192:168.0.6:2000/Server to the registry
On the client side ( Windows ) I looked up the
name rmi://192:168.0.6:2000/Server and got the server reference.
I also tested the application with both the client and server running on linux and it worked satisfactorily.
Thanks
Ravi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic