Java JNDI Context list binding

Description

Java JNDI Context list binding

import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.InitialContext;

public class Main {
   public static void main(String args[]) {
      try {//from w  w  w  .jav  a 2  s  .co  m
         Context ctx = new InitialContext();
         java.util.Enumeration e = ctx.listBindings("java");
         while (e.hasMoreElements()) {
            Binding b = (Binding) e.nextElement();
            System.out.println(b.getName() + " <-> " + b.getObject());
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}



PreviousNext

Related