Obtaining an Initial Context

The first step in using the JNDI name service is to get a context in which to add or find names. The context that represents the entire namespace is called the Initial Context and is represented by a class called javax.naming.InitialContext and is a sub-class of the javax.naming.Context class.

A Context object represents a context that you can use to look up objects or add new objects to the namespace. You can also interrogate the context to get a list of objects bound to that context.

The javax.naming package contains all the simple JNDI classes. Sub-packages within the javax.naming package provide additional JNDI functionality, such as directory-based features like attributes.

The following code creates an initial ...

Get Sams Teach Yourself J2EE™ in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.