Sun Java System Application Server Platform Edition 8.1 2005Q2 Update 2 Developer's Guide

- Previous: Developing Clients Using the ACC
- Next: To access an EJB component from a server-side module

## To access an EJB component from a stand-alone client

1. In your client code, instantiate the `InitialContext`:

       InitialContext ctx = new InitialContext();

   It is not necessary to explicitly instantiate a naming context that points to the CosNaming service.

2. In the client code, look up the home object by specifying the JNDI name of the home object.

   For example:

       Object ref = ctx.lookup("jndi-name");
       BeanAHome = (BeanAHome)PortableRemoteObject.narrow(ref,BeanAHome.class);

   For more information about naming and lookups, see Accessing the Naming Context.

3. Deploy the EJB component to be accessed.

   For more information on deployment, see Tools for Deployment.

4. Copy the following JAR files to the client machine and include them in the classpath on the client side:

   - `appserv-rt.jar` - available at install-dir`/lib`

   - `j2ee.jar` - available at install-dir`/lib`

5. To access EJB components that are residing in a remote system, set the values for the Java Virtual Machine startup options:

       jvmarg value = "-Dorg.omg.CORBA.ORBInitialHost=${ORBhost}"
       jvmarg value = "-Dorg.omg.CORBA.ORBInitialPort=${ORBport}"

   Here ORBhost is the Application Server hostname and ORBport is the ORB port number (default is `3700`).

   This information can be obtained from the `domain.xml` file on the remote system. For more information on `domain.xml` file, see the Sun Java System Application Server Platform Edition 8.1 2005Q2 Update 2 Administration Reference.

6. Run the stand-alone client.

   As long as the client environment is set appropriately and the JVM is compatible, you merely need to run the `main` class.

- Previous: Developing Clients Using the ACC
- Next: To access an EJB component from a server-side module

- © 2010, Oracle Corporation and/or its affiliates