Aditi Dosi
2 min readNov 16, 2022


The Java Naming and Directory Interface (JNDI) is an application programming interface (API) that provides naming and directory functionality to applications written using the Java programming language. It is defined to be independent of any specific directory service implementation. Thus a variety of directories — new, emerging, and already deployed — can be accessed in a common way.

The JNDI is divided into five packages:






The JNDI architecture consists of an API and a service provider interface (SPI). Java applications use the JNDI API to access a variety of naming and directory services. The SPI enables a variety of naming and directory services to be plugged in transparently, thereby allowing the Java application using the JNDI API to access their services.

Is JNDI a protocol?

JNDI is an API specified in Java technology that provides naming and directory functionality to applications written in the Java programming language. It is designed especially for the Java platform using Java’s object model.

What is difference between JNDI and JDBC?

JDBC is Java Database Connectivity API, while JNDI is Java Naming and Directory Interface API. The main thing here is that in a JNDI directory you’re actually storing a JDBC DataSource, so, you’re simply using JDBC to obtain a Connection via JNDI lookup.

What is JNDI data source?

A JNDI DataSource object is a file that contains the configuration details necessary to connect to a database. The DataSource object must be registered on a JNDI server, where it is identified using a JNDI name. You can register your DataSource object directly on your application server via its JNDI service.

What are JNDI properties?

An application resource file has the name jndi.properties. It contains a list of key/value pairs presented in the properties file format (see java. util.Properties).

Here is an example of an application resource file.

java.naming.factory.object=com.sun.jndi.ldap.AttrsToCorba:com.wiz.from.Person java.naming.factory.state=com.sun.jndi.ldap.CorbaToAttrs:com.wiz.from.Person java.naming.factory.control=com.sun.jndi.ldap.ResponseControlFactory java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory java.naming.provider.url=ldap://localhost:389/o=jnditutorial com.sun.jndi.ldap.netscape.schemaBugs=true

Notice that no restrictions apply regarding the type of environment property that you can have in this file.

The JNDI automatically reads the application resource files from all components in the applications’ classpaths and JAVA_HOME/lib/jndi.properties, where JAVA_HOME is the file directory that contains your JRE (Java Runtime Environment). The JNDI then makes the properties from these files available to the service providers and other components that need to use them. Therefore these files should be considered world-readable and should not contain sensitive information, such as clear-text passwords.



Aditi Dosi