The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: IDL
Lesson: The Hello Client-Server Example

Compiling and Running the Hello World Application

This section shows you how to compile and run the server and the client program that together make up the "Hello World" application.

Compiling the Client Application

  1. Compile HelloClient.java:
    javac HelloClient.java HelloApp\*.java
    
  2. Correct any errors in your file and recompile if necessary.
  3. You should see HelloClient.class in the project directory.

Compiling the Server

  1. Compile HelloServer.java:
    javac HelloServer.java HelloApp\*.java
    
  2. Correct any errors in your file and recompile if necessary.
  3. You should see HelloServer.class and HelloServant.class .

Running the Client-Server Application

  1. From an MS-DOS system prompt (Windows) or command shell (UNIX), start the Java IDL name server:
    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 nameserverhost
         -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 nameserverhost 
         -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!!
    

Remember to stop both the tnameserv and the HelloServer processes after the client application returns successfully.

Troubleshooting

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 to use this port for your name server.
Class Definition Not Found Error
If the Java compiler (javac) throws a NoClassDefFoundError, try using -cp (classpath) command line option when compiling the source files.
javac -cp . *.java HelloApp\*.java

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.