import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
public class Main {
public static void main(String[] argv) throws Exception {
String url = "iiop://localhost/";
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, url);
Context ctx = new InitialContext(env);
NamingEnumeration e = ctx.list("child");
while (e.hasMore()) {
NameClassPair entry = (NameClassPair) e.next();
System.out.println(entry.getName());
}
}
}
|