Trail: IDL
|
Lesson: The Hello Client Server Example
|
|
Compiling and Running the Hello World Applicatin
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
- 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 and
HelloServant.class .
Running the Client-Server Application
- From an MS-DOS system prompt (Windows) or command shell (UNIX),
start the Java IDL name server:
tnameserv -ORBInitialPort 1050
- From a second system prompt or shell,
start the Hello server:
java HelloServer -ORBInitialPort 1050
- From a third prompt or shell,
run the Hello application client:
java HelloClient -ORBInitialPort 1050
-
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
|