Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Any difference??  RSS feed

 
Javan Li
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this code:
try {
HelloImpl obj = new HelloImpl();

// Bind this object instance to the name "HelloServer"
Naming.rebind("//myhost/HelloServer", obj);

System.out.println("HelloServer bound in registry");
} catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}

Are there any difference if i replace the Bind line by "Naming.rebind("HelloServer", obj);"
or "Naming.rebind("rmi://server", obj);" ???
Thanx.
 
Javan Li
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any ideas??
 
Chris De Vries
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there is any effective difference between fully specifying the URL in the Naming.rebind() method, or just specifying "HelloServer". The rmiregistry requires that the jre calling Naming.bind() or Naming.rebind() be on the localhost. I recommend however just using Naming.rebind("HelloServer"), as this makes the program easy to run on computers with different hostnames without recompiling.
Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!