| Documentation Contents

# Getting Started with Java IDL
Running the Hello World Application

This topic walks you through running the server and client program that together make up the "Hello World" application.

## Running the Hello World Application

Despite its simple design, the Hello World program lets you learn and experiment with all the tasks required to develop almost any CORBA program that uses static invocation.

This example requires a naming service to make the servant object's operations available to clients. The server needs an object reference to the naming service so that it can publish the references to the objects implementing various interfaces. These object references are used by the clients for invoking methods. The two options for Naming Services shipped with J2SE v.1.4 are `tnameserv`, a transient naming service, and `orbd`, which is a daemon process containing a Bootstrap Service, a Transient Naming Service, a Persistent Naming Service, and a Server Manager. This example uses `orbd`.

When running this example, remember that, when using Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend that you use a port number greater than or equal to 1024. The `-ORBInitialPort` option is used to override the default port number in this example. The following instructions assume you can use port 1050 for the Java IDL Object Request Broker Daemon, `orbd`. You can substitute a different port if necessary. When running these examples on a Windows machine, subtitute a backslash (\) in path names.

To run this client-server application on your development machine:

1. Start `orbd`.

   To start `orbd` from a UNIX command shell, enter:

         orbd -ORBInitialPort 1050 -ORBInitialHost localhost&

   From an MS-DOS system prompt (Windows), enter:

         start orbd -ORBInitialPort 1050 -ORBInitialHost localhost

   Note that `1050` is the port on which you want the name server to run. `-ORBInitialPort` is a required command-line argument. Note that when using Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend that you use a port number greater than or equal to 1024.

   Note that `-ORBInitialHost` is also a required command-line argument. For this example, since both client and server on running on the development machine, we have set the host to `localhost`. When developing on more than one machine, you will replace this with the name of the host. For an example of how to run this program on two machines, see The Hello World Example on Two Machines.

2. Start the Hello server.

   To start the Hello server from a UNIX command shell, enter:

         java HelloServer -ORBInitialPort 1050 -ORBInitialHost localhost&

   From an MS-DOS system prompt (Windows), enter:

         start java HelloServer -ORBInitialPort 1050 -ORBInitialHost localhost

   For this example, you can omit `-ORBInitialHost localhost` since the name server is running on the same host as the Hello server. If the name server is running on a different host, use `-ORBInitialHost` nameserverhost to specify the host on which the IDL name server is running.

   Specify the name server (`orbd`) port as done in the previous step, for example, `-ORBInitialPort 1050`.

3. Run the client application:

         java HelloClient -ORBInitialPort 1050 -ORBInitialHost localhost

   For this example, you can omit `-ORBInitialHost localhost` since the name server is running on the same host as the Hello client. If the name server is running on a different host, use `-ORBInitialHost` nameserverhost to specify the host on which the IDL name server is running.

   Specify the name server (`orbd`) port as done in the previous step, for example, `-ORBInitialPort 1050`.

4. The client prints the string from the server to the command line:

       Hello world!!

The name server, like many CORBA servers, runs until you explicitly stop it. To avoid having many servers running, kill the name server process after the client application returns successfully. To do this from a DOS prompt, select the window that is running the server and enter `Ctrl+C` to shut it down. To do this from a Unix shell, find the process, and kill it.

Previous: Developing the Server
Previous: Developing the Client Application
Next: Using Stringified Object References

Java IDL Home

Copyright © 1993, 2011, Oracle and/or its affiliates. All rights reserved. Please send comments using this Feedback page. | Java Technology