Java

RMI-IIOP

Hello IDL Sample

IBM Developer Kit for Windows(R) Java(TM) 2 Technology Edition, Version 1.2.2

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


Sample: 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: To provide a complete explanation in the steps that follow, we make the following assumptions:
  • A server named aslan.narnia.com.
  • 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%\jre\bin;%JAVA_HOME%\sdk\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:
    1. Go to the samples directory.
    2.      cd %JAVA_HOME%\demo\rmi-iiop
    3. Create the IDL files.
    4.       rmic -idl -d idl hello.RemoteHelloServer
    5. Go to the IDL samples directory.
    6.      cd idl
    7. Run the IDL to java converter to create the client-side .java files.
    8.      idlj hello\RemoteHello.idl
           (Note: the above is equivalent to: idlj -Fclient hello\RemoteHello.idl)
    9. Compile the client IDL application and the client applet.
    10.      javac -d . RemoteHelloApplication.java
           javac -d . RemoteHelloApplet.java
    11. Run the IDL to java converter to create the sever-side .java files. (Note: This step and the following step are optional if you only require an IDL client.)
    12.      idlj -Fall hello\RemoteHello.idl
    13. Compile the IDL server application
    14.      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. Copy the following .class files to your server directory (e.g. %SERVER_ROOT%\java\hello using our sample naming conventions). The idl.html file should be copied to %SERVER_ROOT%.

    Running the IDL Sample

    Starting the name server

    Run the transient 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. If you want to use a browser such as Internet Explorer or Netscape Navigator you will need to modify idl.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 base "Hello" 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 base "Hello" 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 base "Hello" sample .