![]() ![]() ![]() ![]() |
Preparations |
Import the JNDI Packages
The JNDI packages are javax.naming, javax.naming.directory
, javax.naming.event
, javax.naming.ldap
, and javax.naming.spi
. 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.*;Compilation Environment
To compile a program that uses the JNDI, you need access to the JNDI classes. If you are using the Java 2 SDK, v 1.3, the JNDI classes are already included so you need to take no further actions.If you are using an older version of the Java SDK, you first need to download the JNDI classes from the JNDI Web site.
If you are using the Java 2 SDK, v 1.2, you can install the JNDI classes as an installed extension. That is, copy the jndi.jar archive file to the JAVA_HOME/jre/lib/ext directory, where JAVA_HOME is the directory where you have installed the SDK.
If you are not using the JNDI as an installed extension, or are using the JDKTM 1.1, copy the jndi.jar archive file to its permanent location and add its location to your classpath. You can do that by setting the CLASSPATH variable to include the absolute filename of the jndi.jar archive file.
Execution Environment
To run a program that uses the JNDI, you need to have access to the JNDI classes and classes for any service providers that the program uses.If you are using the Java 2 Runtime Environment (JRE), v 1.3, the JNDI classes and service providers for LDAP, COS naming, and the RMI registry are already included. If you are using some other service providers, you need to download and install their archive files in the JAVA_HOME/jre/lib/ext directory, where JAVA_HOME is the directory where you have installed the JRE.
If you are using an older version of the JRE, you first need to download the JNDI classes from the JNDI Web site. There are also some service providers listed at this Web site. You may download these service providers, or use service providers from other vendors.
If you are using the JRE, v 1.2, you can install the JNDI classes as an installed extension. That is, copy the jndi.jar archive file to the JAVA_HOME/jre/lib/ext directory, where JAVA_HOME is the directory where you have installed the JRE.
If you are not using the JNDI as an installed extension, or are using the JRE 1.1, copy the JNDI and service provider archive files to their permanent location and add that location to your classpath. You can do that by setting the CLASSPATH variable to include the absolute filenames of the archive files. For the examples in this trail, you'll need the file system and LDAP service providers. To do that, include the filenames of fscontext.jar, ldap.jar, and providerutil.jar in your CLASSPATH.
![]() ![]() ![]() ![]() |
Preparations |