If you construct an Initial Context using the no argument InitialContext() constructer, how does the initial context 'know' which naming service to connect to?
Does it connect to the localhost?
This is determined by your application server container.
In general, if you use the no-arg constructor, then yes, it will connect to the default JNDI service of the J2EE container running on the localhost.
If you want to read it from another machine, you'll need to set up parameters first.
The actual class of your InitialContext is set as an environment parameter. See the Javadoc for javax.naming.InitialContext for all details.)
Instantiating a subclass using the new InitialContext() looks very strange - at least to me. But it seems to be a built-in feature in the JVM, and you cannot copy this pattern if you want to write something similar.