#

# RMI-IIOP

# Hello IDL Sample

Copyright © 1999 Sun Microsystems, Inc.
Copyright © 1999,2002 International Business Machines Corporation. All Rights Reserved.

## RMI-IIOP Inter-operating with IDL

This sample illustrates how an RMI-IIOP program can inter-operate with a conventional IDL program. It assumes that you have already built and run the RMI-IIOP "Hello World" sample program. This sample shows inter-operability with IDL programs built in Java but of course any programming language which supports IDL could be used.

When you have built the two sets of clients and servers you will be able to run them in the following combinations:

Client | Server
RMI-IIOP | RMI-IIOP
IDL | IDL
RMI-IIOP | IDL
IDL | RMI-IIOP

### The Files

The sample IDL source code is found in the `$JAVA_HOME/demo/rmi-iiop/idl` directory. There you will find the following files:

- `RemoteHelloServer.java` - the server IDL application
- `RemoteHelloApplet.java` - a client IDL applet
- `RemoteHelloApplication.java` - a client IDL application
- `idl.html` - HTML for applet with IDL settings

To provide a complete explanation in the steps that follow, we make the following assumptions:

- A server named `aslan.narnia.com`.
- A writable build directory of `$DEMO_HOME` (for example `$HOME/rmi-iiop/demo`).
- A running HTTP server with root `$SERVER_ROOT`.
Class files resulting from a sample build go into a codebase of `$SERVER_ROOT/java`. Classes in this directory will be loaded remotely; files to be copied into this directory will be listed in the instructions below.

### Setting Up the Environment

Set your `CLASSPATH` environment variable so that the current directory (".") is at the beginning.

Check that your PATH environment variable includes `$JAVA_HOME/bin:$JAVA_HOME/jre/bin`, where `$JAVA_HOME` is the directory where the Java SDK is installed.

### Building the IDL program

After configuring your environment, as explained above, change directory to `$DEMO_HOME/idl`.

1. Copy the demo files to your demo build directory.

          cp $JAVA_HOME/demo/rmi-iiop/idl/*.java .

2. Create the IDL files.

       rmic -idl -d idl hello.RemoteHelloServer

3. Go to the IDL samples directory.

       cd idl

4. Run the IDL to java converter to create the client-side `.java` files.

       idlj -Fclient hello/RemoteHello.idl

5. Compile the client IDL application and the client applet.

       javac -d . RemoteHelloApplication.java
       javac -d . RemoteHelloApplet.java

Note: The next two steps are not required if you only require an IDL client.

6. Run the IDL to java converter to create the sever-side `.java` files.

          idlj -Fall hello/RemoteHello.idl

7. Compile the IDL server application

       javac -d . RemoteHelloServer.java

### Distributing the files

For the client IDL application you must copy the following files to a `hello` sub-directory on your client system.

- `RemoteHelloApplication.class`
- `RemoteHello.class`
- `RemoteHelloOperations.class`
- `RemoteHelloHelper.class`
- `_RemoteHelloStub.class`

Copy the following `.class` files to your server directory (e.g. `$SERVER_ROOT/java/hello` using our sample naming conventions).

- `RemoteHelloOperations.class`
- `_RemoteHelloStub.class`
- `RemoteHello.class`
- `RemoteHelloApplet.class`
- `RemoteHelloHelper.class`

The `idl.html` file should be copied to `$SERVER_ROOT`.

### Running the IDL Sample

#### Starting the name server

Run the name server that will be used to resolve the name RemoteHelloServer that will be used by your applicaton. The name server you run is the same whether you are running an RMI-IIOP program or an IDL one.

       tnameserv

#### Starting your server application

Run the IDL server application, passing parameters to the system with the `-D` option. Note that there must be no space between the `-D` and the property text that follows it.

       java -Dorg.omg.CORBA.ORBInitialHost=aslan.narnia.com hello.RemoteHelloServer

#### Running your application client

Run the application, passing the host address and port number of the server to the application as system properties.

       java -Dorg.omg.CORBA.ORBInitialHost=aslan.narnia.com hello.RemoteHelloApplication

#### Running your applet client

Run the applet using `appletviewer`.

       appletviewer http://aslan.narnia.com/idl.html

It is simplest to test the applet using the `appletviewer` in this way. To use a browser such as Internet Explorer or Netscape Navigator you will need to modify `idl.html` or `iiop.html` to enable the browser to use the Java plug-in. Details of the Java plug-in can be found on the following website: http://java.sun.com/products/ plugin

### Inter-operating

You now have a running IDL client and (optionally) an IDL server application. If you have previously implemented the RMI-IIOP "Hello World" sample you will also have a running RMI-IIOP client and server. You are now ready to inter-operate between heterogeneous clients and servers.

#### IDL client with RMI-IIOP server

1. Start the RMI-IIOP server application as described in the instructions for the RMI-IIOP "Hello World" sample.
2. Run the IDL client (application or applet) as described above.

#### RMI-IIOP client with IDL server

1. Start the IDL server application as described above
2. Run the RMI-IIOP client (application or applet) as described in the instructions for the RMI-IIOP "Hello World" sample .