Previous | Next | Trail Map | The Basics | Preparations

Packages and Classpath

Import the JNDI Packages

The JNDI packages are javax.naming(in the API reference documentation), javax.naming.directory(in the API reference documentation), and javax.naming.spi(in the API reference documentation). The examples in this trail use classes and interfaces from the first two packages. You need to import these two packages into your program, or import individual classes and interfaces that you use. The following two lines import all the classes and interfaces from the two packages javax.naming and javax.naming.directory:
import javax.naming.*;
import javax.naming.directory.*;

Classpath for Compilation

To compile a program that uses the JNDI, you need to have the JNDI classes in your classpath. You can do that by setting the CLASSPATH variable to include the jndi.jar that you've downloaded from the JNDI Web site.

Classpath for Execution

To run a program that uses the JNDI, you need to have the JNDI classes in your classpath. You can do that by setting the CLASSPATH variable to include both jndi.jar and the directory in which you have your program's class files. You also need to include the service provider classes that you'll be using. For the examples in this trail, you'll need the file system and LDAP service providers. To do that, include fscontext.jar, ldap.jar, and providerutil.jar in your CLASSPATH.


Previous | Next | Trail Map | The Basics | Preparations