tags:

views:

100

answers:

3

Hi,

we are wanting to use a JNDI service with our client applications (all written in Java SE 6) and here is our doubt: what are the dependencies? Does the JVM already comes with all the classes that we'll need to access these services? If not, where can we get them?

+2  A: 

Like JDBC (Java Database Connectivity), JNDI is not a service, but a set of interfaces; it allows applications to access many different directory service providers using a standardized API. Just as with JDBC, the JDK contains the JNDI interfaces but does not include a JNDI service provider -- although Sun Microsystems provides adapters for connecting to existing directory service providers, such as LDAP (lightweight directory access protocol), DNS (domain name service), and CORBA. However, you can use one of several free or open source JNDI providers in your J2SE (Java 2 Platform, Standard Edition) applications.

Pascal Thivent
A: 

Yes, Java comes with all classes necessary to use JNDI. See the tutorial for some examples and explanations.

Aaron Digulla
+2  A: 

What you're looking for is package javax.naming, which is part of JavaSE 6.

Sun's guide to JNDI.

Now, unless you're building a web application, JNDI is quite a complex beast. If you can afford to bundle Spring with your application, the lookup of an object with Spring is a no-brainer.

Leonel
Simply using spring as an object repository as opposed to JNDI does not solve the problem of having to work in multiple environments. JNDI allows you to connect to the correct JNDI server and get the environment specific DB data source or JMS connection factory.
Jherico
@Jherico: I'm not suggesting to use spring as an object repo. I'm suggesting to use spring's JNDI facilities instead of configuring JNDI in java code.
Leonel