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 1050&
    

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

         start tnameserv -ORBInitialPort 1050
    

    In this example, port 1050 has been chosen for the naming service. You can change this to a different value if port 1050 is occupied on your system. If the nameserverport is not specified, port 900 will be chosen by default. 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.

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

    On Unix:

    java HelloServer  -ORBInitialPort 1050&
    

    On Windows:

    start java HelloServer  -ORBInitialPort 1050
    

    You can leave out -ORBInitialPort nameserverport if the name server is running on the default port.

    If the Hello server is running on a different host (machine) than the naming service, you would need to specify where the naming service is running when you start the server. To do this, you would use the -ORBInitialHost nameserverhost argument.

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

    java HelloClient   -ORBInitialPort 1050
    

    You can leave out -ORBInitialPort nameserverport if the name server is running on the default port.

    If the Hello client is running on a different host (machine) than the naming service, you would need to specify where the naming service is running when you start the client. To do this, you would use the -ORBInitialHost nameserverhost argument.

  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 (with JRE 1.3) 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:

    On Unix:

         tnameserv -ORBInitialPort 1050&
    

    On Windows:

         start 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. Start the Hello server:

    On Unix:

         java HelloServer -ORBInitialPort 1050 &
    

    On Windows:

         start java HelloServer -ORBInitialPort 1050 
    

    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. Change to the applet directory, Hello.
    2. Start the appletviewer and browse Tutorial.html by typing:
      <path_to_appletviewer_executable>appletviewer Tutorial.html

      Hello world!! prints to the appletviewer frame.

    To run the applet from a Web browser, make sure you have the Java 2 Runtime Environment, Standard Edition, version 1.3.0, which includes the Java Plugin 1.3, and the latest version of your browser, preferably Netscape 6, then:

    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-2001 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA. 94043-1100 USA., All rights reserved.