Java examples for JNDI:Name
Creating an Initial Context to the Naming Service
import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class Main { public void main(String[] argv) { String url = "iiop://localhost/"; Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); env.put(Context.PROVIDER_URL, url); try {/*www . jav a 2 s. c om*/ Context ctx = new InitialContext(env); } catch (NamingException e) { } } }