Hi Qusay
This seems a different set of problems to your earlier issues with getting a ClassNotFoundException when starting the server. Does this mean that you have resolved that problem, or that you are giving up on it for the moment and trying the alternative method?
How can the client connects to the server to start rmiregistry automatically.
Normally the client would not start the server or the RMI Registry. The normal sequence of events would be:
start the server (which may start the RMI Registry programatically, as many here have done)start the client Technically you could start the server from the client. You would then have to ensure that the user did not shut down the client which is also acting as a server. I personally dont like this concept, but if you would like me to expand on it, I will.
The code you have for starting the RMI Registry and registring your service is correct. This should work, and
you should not need to worry about setting the codebase (so you should not see that ClassNotFoundException) or having a policy file.
When you are happy with this way of doing things, you might want to think about
allowing the user to change the port for the RMI Registry (which will require at least two changes in the code snippet you provided)removing hard coded magic numbers (1099) and using constantsmaking your service name a bit more unique than "ServerService".
By the way, shall the user keeps client folder and server folder in its machine, or what?
Probably the examiner will run everything on the one machine, so both client and server folders (do you mean package instead of folder?) on the same machine.
If you want to allow for proper separation of client and server (server on one machine, client on another) then on the client machine you probably only need the server folder with the stub files in it - you should not need the other files that are currently in the server folder.
Regards, Andrew