This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hi: everyone. Sometimes my server starts fine, sometimes it does not. I use "LocateRegistry.createRegistry(port);" to start my server, but just because of which method made me this problem. if port is 1099, my server starts fine; if port is not 1099, I have to use command "rmiregistry" in DOS before starts the server. I want to know how to deal with my problem, I mean that do not using 1099 and any DOS command to start the server.
Yanxin, I suggest to use port 1099 exclusivly. It is the defautl port number, and in most case it will not be accupied by any other process. You can document this choice, and you will have a good reason.
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
You should be able to use any port from within your program without problems. Perhaps you could give us some indication of what errors you see if you do not start an external remote registry? Or show us the code snippet for your starting the registry / registring & looking up your services.
I suspect that you are not specifying the port number in your registration URL. But without further information this is impossible to tell.
It is a good idea to learn how to specify alternate port numbers - otherwise you could end up in a situation where you cannot have more than one application per server . But for the purposes of this assignment, you could get away with hard coding the default port number.
Thanks for your reply, all. My problem has been solved. At the beginning my code is that LocateRegistry.createRegistry(2000); Naming.rebind("//localhost/test", test); but it is wrong, afterward, I change it into LocateRegistry.createRegistry(2000).rebind("//localhost/test", test); it works fine.
and in the client said, my right code is LocateRegistry.getRegistry("localhost", 2000).lookup("//localhost/test");
now my code works fine. thanks for your reply again. : )