+1  A: 

java.rmi.server.UnicastRemoteObject is used for exporting a remote object with Java Remote Method Protocol (JRMP) and obtaining a stub that communicates to the remote object.

For the constructors and static exportObject methods below, the stub for a remote object being exported is obtained ...

There you should follow the Javadoc

stacker
btw, your server code version 1 confused me, locateRegistry wouldn't work because it's not declared
stacker
thanks for your reply, but it does not really clear things up for me.... do you like the code better as it is now?
CatholicEvangelist
;-) Now the compiler likes your code better, the result is the same the object is registered under the provided name in the RMI registry and is accessible by clients. The only difference is that rebind is more fault tolerant than bind (If already bound). I will upvote your question to attract more guys
stacker
thanks again - so the first version is somewhat safer, right? in almost all tutorials a RMI object is exported in the latter manner, but IMO I prefer the first version over the other...
CatholicEvangelist
As already mentioned they're equivalent the difference is rebind would not throw an AlreadBoundExeption, I also prefer your first option. In your exam you could describe one way and mention that there's another option.
stacker
well, I've rocked the examination - thx for your input anyway... :-)
CatholicEvangelist
+1  A: 

There are two questions here.

  1. You can either extend UnicastRemoteObject or call UnicastRemoteObject.exportObject(). Which you do is up to you. The first is simple and automatic; the second means you can extend another class.

  2. You can either use an external RMI Registry or create it yourself inside your server JVM. Again which you do is up to you, there are advantages both ways.

These two questions have no interaction.

EJP