import javax.naming.*;
import java.io.File;
import java.util.Hashtable;
/**
* Demonstrates how to look up an object.
*
* usage: java Lookup
*/
class Lookup {
public static void main(String[] args) {
// Set up the environment for creating the initial context
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file:/tmp/tutorial");
try {
// Create the initial context
Context ctx = new InitialContext(env);
// Perform lookup and cast to target type
File f = (File) ctx.lookup("abc.txt");
System.out.println(f);
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
System.out.println("Lookup failed: " + e);
}
}
}