# 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 or applet.

## 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. To run this client-server application on your development machine:

1. Start the Java IDL Name Server. To do this from a UNIX command shell, enter:

            tnameserv -ORBInitialPort nameserverport

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

            start tnameserv -ORBInitialPort nameserverport

   Note that nameserverport is the port on which you want the name server to run. If you do not specify this, port 900 will be chosen by default. Also note that 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.

2. From a second prompt or shell, start the Hello server:

       java HelloServer -ORBInitialHost namerserverhost -ORBInitialPort nameserverport

   Note that nameserverhost is the host on which the IDL name server is running. You can omit `-ORBInitialHost` nameserverhost if the name server is running on the same host as the Hello server. You can leave out `-ORBInitialPort` nameserverport if the name server is running on the default port.

3. From a third prompt or shell, run the Hello application client:

       java HelloClient  -ORBInitialHost namerserverhost -ORBInitialPort nameserverport

   Note that nameserverhost is the host on which the IDL name server is running. You can omit `-ORBInitialHost` nameserverhost if the name server is running on the same host as the Hello client. You can leave out `-ORBInitialPort` nameserverport if the name server is running on the default port.

4. The client prints the string from the server 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 after the client application returns successfully.

## Running the Hello World Applet

You can run the applet from either a Java-enabled Web browser or from the Applet Viewer. In either case, you must run the Name Server and the HelloServer prior to invoking the applet. To run the applet,

1. From an MS-DOS system prompt (Windows) or command shell (UNIX), start the Java IDL name server:

            tnameserv -ORBInitialPort 1050 &

   In this example, the nameserverport, which is the port on which you want the name server to run, is set to 1050. If you do not specify this, port 900 will be chosen by default. Also note that 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.

2. From a second prompt or shell, start the Hello server:

       java HelloServer -ORBInitialHost namerserverhost -ORBInitialPort 1050 &

   Note that nameserverhost is the host on which the IDL name server is running. You can omit `-ORBInitialHost` nameserverhost if the name server is running on the same host as the Hello server. In this example, the `ORBInitialPort`, which is the port on which you want the name server to run, is set to 1050. If you do not specify this, port 900 will be chosen by default. Also note that 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.

3. Run the applet.

   To run the applet from the appletviewer,

   1. Open another prompt or shell.
   2. Change to the applet directory, `Hello`.
   3. Start the appletviewer and browse `Tutorial.html` by typing:

          appletviewer Tutorial.html

      `Hello world!!` prints to the appletviewer frame.

   To run the applet from a Web browser,

   1. Open the Web browser.
   2. Open the file `Tutorial.html`.

      `Hello world!!` prints in the browser frame.

If the applet does not run in the Web browser, make sure you have the Java 2 Runtime Environment, Standard Edition, version 1.3.0, which includes the Java Plugin 1.3. This plugin is needed to run the applet and may not be present in older Web browsers.

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 after the client application returns successfully.

## Troubleshooting

### Security violation: method verification error

Make sure you have the Java 2 Runtime Environment, Standard Edition, version 1.3.0, which includes the Java Plugin 1.3. This plugin is needed to run the applet and may not be present in older Web browsers. It can be downloaded from http://java.sun.com/products/plugin/index.html.

### Specifying ORB Initial Port

The default ORB Initial Port is port 900. If you prefer, you can omit the port specifications if you start the name server on port 900. Using Solaris software, you must become root to start a process on a port under 1024. Remember to exit from root access before continuing with the tutorial if you choose this port for your name server.

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

Home

Copyright © 1996-2000 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA. 94043-1100 USA., All rights reserved.