Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
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
- Compile
HelloClient.java
:javac HelloClient.java HelloApp\*.java- Correct any errors in your file and recompile if necessary.
- You should see
HelloClient.class
in the project directory.Compiling the Server
- Compile
HelloServer.java
:javac HelloServer.java HelloApp\*.java- Correct any errors in your file and recompile if necessary.
- You should see
HelloServer.class
andHelloServant.class
.Running the Client-Server Application
- From an MS-DOS system prompt (Windows) or command shell (UNIX), start the Java IDL name server:
Note thattnameserv -ORBInitialPort nameserverportnameserverport
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.
- From a second prompt or shell, start the Hello server:
Note thatjava HelloServer -ORBInitialHost nameserverhost -ORBInitialPort nameserverportnameserverhost
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.
- From a third prompt or shell, run the Hello application client:
Note thatjava HelloClient -ORBInitialHost nameserverhost -ORBInitialPort nameserverportnameserverhost
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.
- The client prints the string from the server to the command line:
Hello world!!Remember to stop both the
tnameserv
and theHelloServer
processes after the client application returns successfully.
- 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 aNoClassDefFoundError
, try using-cp
(classpath) command line option when compiling the source files.javac -cp . *.java HelloApp\*.java
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.