Extending the Hello JNDI Example..

..demonstrating how System Properties can be used instead of a HashTable in the Constructor!

So the code I have is:
import javax.naming.*;
import java.io.File;
 
/**
 * User: Koray Tugay (koray@tugay.biz)
 * Date: 7/30/2016
 * Time: 9:49 AM
 */
public class JNDIHello {
 
    public static void main(String[] args) throws Exception {
        final InitialContext context = new InitialContext();
        final File file = (File) context.lookup("TestClass.java");
        System.out.println("File exists? " + file.exists());
    }
 
    final static String URL =
            "file:///Users/Koray Tugay/Development/studentform/src/main/java/biz/tugay";
    final static String CONTEXT_FACTORY
            = "com.sun.jndi.fscontext.RefFSContextFactory";
 
    static {
        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, CONTEXT_FACTORY);
        System.setProperty(Context.PROVIDER_URL, URL);
    }
 
}
which is very identical to the previous post really..

But look at this particular part:
public static void main(String[] args) throws Exception {
    final InitialContext context = new InitialContext();
    final File file = (File) context.lookup("TestClass.java");
    System.out.println("File exists? " + file.exists());
}

OMG!

What kind of dark magic is going on in here? The mystery is solved when you see the static initializer block! Also check out this link!

The output will be:
File exists? true