In the first case, this means that your server class programatically starts a new instance of the naming service/registry on the ip,port,etc. specified, and binds itself to it. When your server class shuts down, so does the naming service.
In the second case, your server class binds itself to the naming service/registry already running on the specified ip,port,etc. This registry could have been started from another program or the command line - but it is independent of your server class and doesn't shutdown if your server does.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.