Previous

Building Hello World under the Solaris Operating System

The source code for the Hello World example is located in [Path_to_JDK]/docs/guide/idl/examples/Hello. The following instructions assume you can use port 1050 for the Java IDL name server. Substitute a different port if necessary. (Note that to use a port below 1024, you need root access on Unix machines and administrator privileges on Wintel machines.) Substitute the completely-qualified path to your JDK installation for [Path_to_JDK]

Note: Steps 2 and 3 require you to have downloaded and installed the idltojava compiler.

  1. Change to the example directory:
    cd [Path_to_JDK]/docs/guide/examples/hello
  2. Make certain that the idltojava compiler [Path_to_JDK]/bin) and the Java binaries are included in your path environment variable.

  3. Compile the IDL file with idltojava to create stubs and skeletons.
    Note: idltojava is hard-coded to use a default preprocessor. On Solaris machines, it uses the path /usr/ccs/lib/cpp when looking for the preprocessor. You can change the preprocessor that idltojava uses by setting two environment variables: CPP and CPARGS. Set CPP to the full pathname of the preprocessor you want to use. Set CPARGS to the complete list of arguments to be passed to the preprocessor. You can also turn off the preprocessor by adding -fno-cpp to the idltojava command line. More information is available in the idltojava reference page that is downloaded with the idltojava compiler.
    idltojava Hello.idl
  4. Compile the Java files, including the stubs and skeletons:
    javac *.java HelloApp/*.java
    
  5. Start the Java IDL name server:
    tnameserv -ORBInitialPort 1050 &
    

    You will see something like the following:

    Initial Naming Context:
    IOR:000000000000002849444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f6e746578743a312e3000000000010000000000000034000100000000000974687572626c6967000086760000001cafabcafe0000000233de2f5c00000000000000080000000000000000
    TransientNameServer: setting port for initial object references to: 1050
    

    The server runs in the background; you see no more evidence of it until you run the client program.

  6. Start the Hello server:
    java HelloServer -ORBInitialPort 1050 &
    
  7. Run the Hello application client:
    java HelloClient  -ORBInitialPort 1050
    

    The string prints to the command line:

    Hello world!!
    

The name server and the Hello World server, like many CORBA servers, run until you explicitly stop them. To avoid having many servers running, kill the server processes before proceeding to Section One.


Previous