Member-only story
Java Naming and Directory Interface
3 min readDec 14, 2024
What is JNDI?
JNDI (Java Naming and Directory Interface) is an API in Java that provides naming and directory functionality, enabling Java applications to discover and access resources in a distributed system. It allows applications to look up objects by a name in a directory service (e.g., a JNDI registry) and retrieve those objects for use.
Why is JNDI Used?
JNDI serves several purposes in enterprise Java applications:
- Resource Discovery: It enables applications to discover resources (e.g., DataSources, EJBs, Mail Sessions) in a distributed environment.
- Decoupling: By allowing the application to look up resources at runtime, it decouples the resource configurations from the application code, making the system more flexible and easier to manage.
- Interoperability: It supports integration with multiple directory services like LDAP, DNS, NIS, and RMI registries.
- Centralized Configuration: JNDI allows administrators to define and manage resources centrally, simplifying deployment and configuration.
Practical Examples of JNDI
- Database Connection Pooling: JNDI is commonly used to look up a DataSource for database connections in Java EE applications.










