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

Trail: IDL
Lesson: The Hello Client Server Example

Compiling and Running the Hello World Application

By now, you've written the Hello.idl file, run the idltojava compiler on it, and you've written the code for the client and server. Your project directory should look something like this:

[PENDING: need new figure now]


Note to UNIX Users:  You should substitute slashes (/) for the backslashes (\) in all paths in this document.

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 1050 
    
  2. From a second system prompt or shell, start the Hello server:
    java HelloServer -ORBInitialPort 1050
    
  3. From a third prompt or shell, run the Hello application client:
     
    java HelloClient -ORBInitialPort 1050
    
  4. The client prints the string from the server to the command line:
    Hello world!!
    

Remember to stop both the NameServer 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