File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes what's the use of InitialContext? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "what Watch "what New topic

what's the use of InitialContext?

Viv Gupta

Joined: Dec 01, 2005
Posts: 15
Hi All,

I want to know what's the use of InitialContext? what happens when we write

ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
The javax.naming.InitialContext class implements the Context interface and serves as our entry point to a naming system. To use JNDI to access objects in a naming system, you must first create an InitialContextobject. The InitialContext constructor takes a set of properties, in the form of a java.util.Hashtable or one of its subclasses, such as a Properties object. Here is how we created an InitialContext in the Lookup example:

Properties props = new Properties();
props.put(Context.PROVIDER_URL, "file:///");

// Create the initial context from the properties we just created
Context initialContext = new InitialContext(props);


Ujjwal Soni

Ujjwal B Soni <baroda, gujarat, india> <+918866008962>
"Helping hands are better than praying lips......"
Lave Kulshreshtha
Ranch Hand

Joined: Oct 21, 2007
Posts: 106
Refer to


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, ITIL V3 Foundation Certification
I agree. Here's the link:
subject: what's the use of InitialContext?
It's not a secret anymore!